本文整理汇总了PHP中Mongo::batchInsert方法的典型用法代码示例。如果您正苦于以下问题:PHP Mongo::batchInsert方法的具体用法?PHP Mongo::batchInsert怎么用?PHP Mongo::batchInsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mongo
的用法示例。
在下文中一共展示了Mongo::batchInsert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: batchInsert
public function batchInsert($a, $options = array())
{
try {
$options = array_merge($options, array('safe' => TRUE));
return parent::batchInsert($a, $options);
} catch (MongoCursorException $e) {
show_error("MongoDB batchInsert failed: {$e->getMessage()}", 500);
}
}
示例2: testBatchInsert
public function testBatchInsert()
{
$this->assertTrue($this->object->batchInsert(array('z' => (object) array('foo' => 'bar'))));
$a = array((object) array("x" => "y"), (object) array("x" => "z"), (object) array("x" => "foo"));
$this->object->batchInsert($a);
$this->assertEquals(4, $this->object->count());
$cursor = $this->object->find(array("x" => array('$exists' => 1)))->sort((object) array("x" => -1));
$x = $cursor->getNext();
$this->assertEquals('z', $x['x']);
$x = $cursor->getNext();
$this->assertEquals('y', $x['x']);
$x = $cursor->getNext();
$this->assertEquals('foo', $x['x']);
}