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


PHP MongoCursor::find方法代码示例

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


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

示例1: testFind

 public function testFind()
 {
     $this->object->storeFile('tests/somefile');
     $cursor = $this->object->find();
     $this->assertTrue($cursor instanceof MongoGridFSCursor);
     $file = $cursor->getNext();
     $this->assertNotNull($file);
     $this->assertTrue($file instanceof MongoGridFSFile);
 }
开发者ID:redmeadowman,项目名称:mongo-php-driver,代码行数:9,代码来源:MongoGridFSTest.php

示例2: testStaticTimeout

 /**
  * @expectedException MongoCursorTimeoutException
  */
 public function testStaticTimeout()
 {
     $this->markTestSkipped("for now");
     return;
     MongoCursor::$timeout = 1;
     for ($i = 0; $i < 1000; $i++) {
         $this->object->insert(array("x" => "sdfjnaireojaerkgmdfkngkdsflngklsgntoigneorisgmsrklgd{$i}", "y" => $i));
     }
     $rows = $this->object->find(array('$eval' => '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;'));
     foreach ($rows as $row) {
     }
     MongoCursor::$timeout = 30000;
 }
开发者ID:kph11,项目名称:mongo-php-driver,代码行数:16,代码来源:SlowTests.php

示例3: testTimeout2

 public function testTimeout2()
 {
     $cmd = $this->object->db->selectCollection('$cmd');
     for ($i = 0; $i < 10000; $i++) {
         $this->object->insert(array("name" => "joe" . $i, "interests" => array(rand(), rand(), rand())));
     }
     // shouldn't time out
     $r = $this->object->find()->timeout(5000)->getNext();
     // not testing functionality, just making sure it's testing the right data
     $this->assertEquals("joe", substr($r['name'], 0, 3));
     // shouldn't time out, does take a while
     $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;';
     $r = $cmd->find(array('$eval' => $query))->limit(-1)->getNext();
 }
开发者ID:redmeadowman,项目名称:mongo-php-driver,代码行数:14,代码来源:SlowTests.php

示例4: testPartial

 public function testPartial() {
     $cursor = $this->object->find();
     $cursor->partial()->partial(true)->partial(false);
     $cursor->hasNext();
     $cursor->reset();
     $cursor->partial(true);
     $cursor->hasNext();
 }
开发者ID:neurodrone,项目名称:mongo-php-driver,代码行数:8,代码来源:MongoCursorTest.php

示例5: testExplainReset

 public function testExplainReset()
 {
     $this->object->insert(array("x" => "abc"), array('safe' => true));
     $cursor = $this->object->find();
     $qp = $cursor->explain();
     $info = $cursor->info();
     $this->assertTrue(!array_key_exists('$explain', $info['query']));
     $this->assertTrue(array_key_exists('$query', $info['query']));
     $doc = $cursor->getNext();
     $this->assertEquals('abc', $doc['x'], json_encode($doc));
 }
开发者ID:redmeadowman,项目名称:mongo-php-driver,代码行数:11,代码来源:MongoCursorTest.php

示例6: testExplainLimit

 public function testExplainLimit()
 {
     $this->object->drop();
     for ($i = 0; $i < 100; $i++) {
         $this->object->save(array("x" => $i));
     }
     $q = array("x" => array('$gt' => 50));
     $soft = $this->object->find($q)->limit(20)->explain();
     $hard = $this->object->find($q)->limit(-20)->explain();
     $this->assertEquals(20, $soft['n']);
     $this->assertEquals(20, $hard['n']);
 }
开发者ID:petewarden,项目名称:mongo-php-driver,代码行数:12,代码来源:MongoCursorTest.php


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