本文整理汇总了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);
}
示例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;
}
示例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();
}
示例4: testPartial
public function testPartial() {
$cursor = $this->object->find();
$cursor->partial()->partial(true)->partial(false);
$cursor->hasNext();
$cursor->reset();
$cursor->partial(true);
$cursor->hasNext();
}
示例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));
}
示例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']);
}