yii\mongodb\ActiveQuery::modify PHP 메소드

modify() 공개 메소드

Warning: in case 'new' option is set to 'false' (which is by default) usage of this method may lead to unexpected behavior at some Active Record features, because object will be populated by outdated data.
public modify ( array $update, array $options = [], Connection $db = null ) : ActiveRecord | array | null
$update array update criteria
$options array list of options in format: optionName => optionValue.
$db Connection the Mongo connection used to execute the query.
리턴 ActiveRecord | array | null the original document, or the modified document when $options['new'] is set. Depending on the setting of [[asArray]], the query result may be either an array or an ActiveRecord object. Null will be returned if the query results in nothing.
    public function modify($update, $options = [], $db = null)
    {
        $row = parent::modify($update, $options, $db);
        if ($row !== null) {
            $models = $this->populate([$row]);
            return reset($models) ?: null;
        } else {
            return null;
        }
    }