Does anyone know if there is a way to make a query with DAO?
UPDATE my_table SET int_field = int_field + 1;
So I want to increment some field like this:
['int_field' => 'int_field +1']
And this way is totally wrong because of value converting to integer.
Is raw sql the only option?
['int_field' => new Expression("int_field + 1")]
Oh, right. AR method is helpful and exactly this but not what op wanted. Sorry.
Yii::$app->db->createCommand('UPDATE my_table SET int_field = int_field+1')->execute();
If not, where are you trying to execute the sql and what is the purpose?
Thanks! It seems that’s the thing I’m looking for!