downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

MongoId::__construct> <MongoGridFSCursor::key
[edit] Last updated: Fri, 18 Sep 2009

view this page in

The MongoId class

Увод

A unique identifier created for database objects.

Синтаксис за класове

MongoId
MongoId {
/* Methods */
__construct ([ string $id = NULL ] )
public string __toString ( void )
}

Съдържание



add a note add a note User Contributed Notes MongoId
alex dot turpin at gmail dot com 11-Jul-2011 09:15
If you need to get the actual ID string, and you try the usual way, PHP will whine because it starts with a dollar sign and it thinks it's a variable. Instead, use this notation:

<?php
    $mongoid
->{'$id'} //Get the $id property of a MongoId object
?>
sararschreiber at gmail dot com 12-Oct-2010 12:23
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();

?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites