本文整理汇总了PHP中Operator::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Operator::toArray方法的具体用法?PHP Operator::toArray怎么用?PHP Operator::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operator
的用法示例。
在下文中一共展示了Operator::toArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findAndUpdate
/**
* Find first document and update it
*
* @param Operator $operator operations with document to update
* @param bool $upsert if document not found - create
* @param bool $returnUpdated if true - return updated document
*
* @return null|Document
*/
public function findAndUpdate(Operator $operator, $upsert = false, $returnUpdated = true)
{
$mongoDocument = $this->collection->getMongoCollection()->findAndModify($this->expression->toArray(), $operator ? $operator->toArray() : null, $this->fields, array('new' => $returnUpdated, 'sort' => $this->sort, 'upsert' => $upsert));
if (!$mongoDocument) {
return null;
}
return $this->collection->hydrate($mongoDocument, $this->isDocumentPoolUsed());
}
示例2: testAddToSetEach_KeyExists
public function testAddToSetEach_KeyExists()
{
$operator = new Operator();
$operator->addToSetEach('param', array('value1', 'value2'));
$operator->addToSetEach('param', array('value3', 'value4'));
$this->assertEquals(array('$addToSet' => array('param' => array('$each' => array('value1', 'value2', 'value3', 'value4')))), $operator->toArray());
}