Skip to content

Instantly share code, notes, and snippets.

@yesidays
Created May 22, 2012 05:35
Show Gist options
  • Save yesidays/2766840 to your computer and use it in GitHub Desktop.
Save yesidays/2766840 to your computer and use it in GitHub Desktop.
CI + MongoDB
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