note 100386 modified in class.mongoid by chx
[email protected] Tue, 22 Feb 2011 08:37:27 -0800
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
this is useful for querying for an object by id, given the id's hex:
<?php
$userid = '4cb4ab6d7addf98506010000';
$theObjId = new MongoId($userid);
$connection = new Mongo();
$db = $connection->thedb->users;
// this will return our matching entry.
$item = $db->findOne(array("_id" => $theObjId));
$connection->close();
?>
--was--
this is useful for querying for an object by id, given the id's hex:
<?php
$userid = 4cb4ab6d7addf98506010000;
$theObjId = new MongoId($userid);
$connection = new Mongo();
$db = $connection->thedb->users;
// this will return our matching entry.
$item = $db->findOne(array("_id" => $theObjId));
$connection->close();
?>
http://php.net/manual/en/class.mongoid.php