public function set($value, $atomic = true)
{
$this->requiresCurrentField();
if ($atomic) {
$this->newObj['$set'][$this->currentField] = $value;
return $this;
}
if (strpos($this->currentField, '.') === false) {
$this->newObj[$this->currentField] = $value;
return $this;
}
$keys = explode('.', $this->currentField);
$current =& $this->newObj;
foreach ($keys as $key) {
$current =& $current[$key];
}
$current = $value;
return $this;
}
/** * Set the current field to a value. * * This is only relevant for insert, update, or findAndUpdate queries. For * update and findAndUpdate queries, the $atomic parameter will determine * whether or not a $set operator is used. * * @see Expr::set() * @see http://docs.mongodb.org/manual/reference/operator/set/ * @param mixed $value * @param boolean $atomic * @return self */ public function set($value, $atomic = true) { $this->expr->set($value, $atomic && $this->query['type'] !== Query::TYPE_INSERT); return $this; }