当前位置: 首页>>代码示例>>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;未经允许,请勿转载。