本文整理匯總了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());
}