當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mongo::findOne方法代碼示例

本文整理匯總了PHP中Mongo::findOne方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mongo::findOne方法的具體用法?PHP Mongo::findOne怎麽用?PHP Mongo::findOne使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mongo的用法示例。


在下文中一共展示了Mongo::findOne方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testRef

 public function testRef()
 {
     ini_set("mongo.cmd", ":");
     $this->object->insert(array("_id" => 123, "hello" => "world"));
     $this->object->insert(array("_id" => 456, "ref" => array(":ref" => "bar", ":id" => 123)));
     $ref = $this->object->findOne(array("_id" => 456));
     $obj = MongoDBRef::get($this->object->db, $ref["ref"]);
     $this->assertNotNull($obj);
     $this->assertEquals("world", $obj["hello"], json_encode($obj));
 }
開發者ID:rjonker,項目名稱:mongo-php-driver,代碼行數:10,代碼來源:CmdSymbolTest.php

示例2: testGetDBRef

 public function testGetDBRef()
 {
     for ($i = 0; $i < 50; $i++) {
         $this->object->insert((object) array('x' => rand()));
     }
     $obj = $this->object->findOne();
     $ref = $this->object->createDBRef($obj);
     $obj2 = $this->object->getDBRef($ref);
     $this->assertNotNull($obj2);
     $this->assertEquals($obj['x'], $obj2['x']);
 }
開發者ID:redmeadowman,項目名稱:mongo-php-driver,代碼行數:11,代碼來源:MongoObjectsTest.php

示例3: __read

 /**
  * Method used to read from a database session.
  *
  * @param mixed $id The key of the value to read
  * @return mixed The value of the key or false if it does not exist
  * @access private
  */
 public function __read($id)
 {
     // obtain a read lock on the data, or subsequently wait for
     // the lock to be released
     //		$this->_lock($id);
     // exclude results that are inactive or expired
     $result = $this->_mongo->findOne(array('session_id' => $id, 'expiry' => array('$gte' => time()), 'active' => 1));
     if (isset($result['data'])) {
         $this->_session = $result;
         return $result['data'];
     }
     return '';
 }
開發者ID:radig,項目名稱:CakeMongoSession,代碼行數:20,代碼來源:cake_mongo_session.php


注:本文中的Mongo::findOne方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。