0

I tried printing this query using createCommand, but it is giving boolean error.

RtsSellerEmail::updateAll(['last_check_at' => time() ], ['seller_id' => $sellerId, 'is_sent' => 0, 'email_type' => $emailTypes, ['>', 'created', $release_date]]);

  • RtsSellerEmail::updateAll(['last_check_at' => time() ], ['and', ['seller_id' => $sellerId, 'is_sent' => 0, 'email_type' => $emailTypes], ['>', 'created', $release_date]]); – Bizley Mar 30 '21 at 13:33
  • @SumitAnand why are you print this query? https://stackoverflow.com/questions/25469689/yii2-update-field-with-query-builder – Shringiraj Dewangan Mar 31 '21 at 10:06
  • If your purpose is just debug, you should find all the performed queries in the [debug toobar](https://code.tutsplus.com/tutorials/programming-with-yii2-using-the-debugger--cms-26910) – Gianpaolo Scrigna Apr 05 '21 at 13:04

1 Answers1

0

There is no option to get query for ModelName::updateAll(...)

But we can generate Raw Query using below pattern

$command = Yii::$app->db->createCommand();
echo $command->update(RtsSellerEmail::tableName(),$columns ,$condition)->rawSql;

we can use 'sql' or 'getRawSql()' insted of 'rawSql' to generate raw query