当前位置: 首页>>代码示例>>PHP>>正文


PHP MongoCursor::findOne方法代码示例

本文整理汇总了PHP中MongoCursor::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoCursor::findOne方法的具体用法?PHP MongoCursor::findOne怎么用?PHP MongoCursor::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoCursor的用法示例。


在下文中一共展示了MongoCursor::findOne方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testOverwrite

 public function testOverwrite()
 {
     $fh1 = fopen('tests/somefile', 'r');
     $fh2 = fopen('mongo.c', 'r');
     $this->object->storeFile($fh1, array('_id' => 1));
     $this->object->storeFile($fh2, array('_id' => 1));
     $file = $this->object->findOne();
     $this->assertEquals(129, $file->file['length'], json_encode($file->file));
 }
开发者ID:redmeadowman,项目名称:mongo-php-driver,代码行数:9,代码来源:MongoGridFSTest.php

示例2: testMD5

 public function testMD5()
 {
     $mid = $this->object->storeFile("mongo.c");
     $gid = $this->object->storeFile("gridfs.c");
     $mongo = $this->object->findOne(array("_id" => $mid));
     $gridfs = $this->object->findOne(array("_id" => $gid));
     $this->assertNotEquals($mongo->file['md5'], $gridfs->file['md5']);
     $this->assertEquals($mongo->file['md5'], md5(file_get_contents("mongo.c")));
     $this->assertEquals($gridfs->file['md5'], md5(file_get_contents("gridfs.c")));
 }
开发者ID:petewarden,项目名称:mongo-php-driver,代码行数:10,代码来源:MongoGridFSTest.php

示例3: testTimeout3

 public function testTimeout3()
 {
     for ($i = 0; $i < 10000; $i++) {
         $this->object->insert(array("name" => "joe" . $i, "interests" => array(rand(), rand(), rand())));
     }
     $cmd = $this->object->db->selectCollection('$cmd');
     $query = 'r = 0; cursor = db.c.find(); while (cursor.hasNext()) { x = cursor.next(); for (i=0; i<200; i++) { if (x.name == "joe"+i) { r++; } } } return r;';
     $count = 0;
     for ($i = 0; $i < 3; $i++) {
         $cursor = $cmd->find(array('$eval' => $query))->limit(-1)->timeout(500);
         try {
             $x = $cursor->getNext();
             $this->assertFalse(true, json_encode($x));
         } catch (MongoCursorTimeoutException $e) {
             $count++;
         }
     }
     $this->assertEquals(3, $count);
     $x = $this->object->findOne();
     $this->assertNotNull($x);
     $this->assertTrue(array_key_exists('name', $x), json_encode($x));
     $this->assertTrue(array_key_exists('interests', $x), json_encode($x));
 }
开发者ID:kph11,项目名称:mongo-php-driver,代码行数:23,代码来源:SlowTests.php

示例4: test__construct4

 /**
  * @expectedException MongoException
  */
 public function test__construct4()
 {
     $this->object->findOne(array(), array("id", 123));
 }
开发者ID:redmeadowman,项目名称:mongo-php-driver,代码行数:7,代码来源:MongoCursorTest.php

示例5: testEmpty

 public function testEmpty() {
     $this->object->storeFile('tests/empty');
     $file = $this->object->findOne();
     $this->assertEquals(0, $file->file['length']);
 }
开发者ID:neurodrone,项目名称:mongo-php-driver,代码行数:5,代码来源:MongoGridFSTest.php


注:本文中的MongoCursor::findOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。