note 100386 modified in class.mongoid by chx

From: Date: Tue, 22 Feb 2011 16:37:27 +0000
Subject: note 100386 modified in class.mongoid by chx
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-177222@lists.php.net to get a copy of this message
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

« previous php.notes (#177222) next »