public pushEachPosition ( string $field, integer $position ) : |
||
$field | string | |
$position | integer | non-negative number that corresponds to the position in the array, based on a zero-based index |
return |
public function pushEachPosition($field, $position)
{
$position = (int) $position;
// add modifiers
if ($position <= 0) {
throw new Exception('Position must be greater 0');
}
if (!isset($this->operators['$push'][$field]['$each'])) {
throw new Exception('Field ' . $field . ' must be pushed with $each modifier');
}
$this->operators['$push'][$field]['$position'] = $position;
return $this;
}