Created
May 22, 2012 05:35
-
-
Save yesidays/2766840 to your computer and use it in GitHub Desktop.
CI + MongoDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ejemplos de código CI + Mongo | |
Buscar un usuario y ordenar por datetime descendentemente. | |
<?php | |
$collection = "school"; | |
$query = $this->mongo_db->where(array('user' => $idUser))->order_by(array('datetime' => 'desc'))->get($collection); | |
?> | |
Guardar datos en la colección | |
<?php | |
$data = array ( "name" => "Yesi", "lastName" => "Diaz"); | |
function saveUser($collection,$data) { | |
$this->mongo_db->add_index($collection, array('idUser' => 'ASC'), array('unique' => TRUE)); | |
$insert = $this->mongo_db->insert($collection,$data); | |
$this->mongo_db->close(); | |
return; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment