Just learn MongoDB, now the information on the Internet is relatively small, read a MongoDB authoritative guide, the content is not very comprehensive. 708 together to find some of the MONGO database basic additions and deletions to check operations.
$mongo = new MONGO ();
$db = $mongo->selectdb (' Test ');
$collection = $db->selectcollection (' foo ');
Insert $array = array (' name ' => ' John ', ' sex ' => ' male ');
$bool = $collection->insert ($array);
Update $where = array (' name ' => ' John ');
$newdata = Array (' name ' => ' John ', ' sex ' => ' female ');
$bool = $collection->update ($where, Array (' $set ', $newdata));
Batch update $where = array (' Y ' => ' 9 ');
$newdata = Array (' y ' =>10);
$bool = $collection->update ($where, Array (' $set ' => $newdata), Array ("multiple" => true);
Delete field $where = Array (' A ' => ' 1 ');
$bool = $collection->update (Array (' B ' => ' t '), Array (' $unset ' =>array (' C ' =>1));
Echo ' <pre> '; var_dump ($bool); exit;
$push $bool = $collection->update (Array (' A ' => ' 1 '), Array (' $push ' =>array (' wow ')));
Echo ' <pre> '; var_dump ($bool); exit;
Delete document $where = Array (' name ' => ' John ');
$bool = $collection->remove ($where);
Group $keys = Array ("category" => 1);
$initial = Array ("Count" => 0); $reduce = "Function (obj, prev) {prev.count++}";
$condition = Array (' condition ' => Array (' Category ' => array (' $exists ' => 1));
$g = $collection->group ($keys, $initial, $reduce, $condition);
Echo ' <pre> ';p rint_r ($g); exit;
Distinct $retval = $collection->distinct ("Zip-code", Array (' Stuff ' => ' foo '));
Query, sort $where = Array (' Y ' =>array (' $exists ' =>true, ' $gte ' =>5, ' $lt ' =>10));
$result = $collection->find ($where)->sort (Array (' Y ' =>-1));
$arr = Array ();
foreach ($result as $key => $value) {$arr [] = $value;} Echo ' <pre> ';p rint_r ($arr);