Generated SQL from ActiveQuery

Hello,

at one point I build an complex ActiveQuery, and as it is not working as expexted, I would like to output the generated SQL.

But, how can I do this? I don’t want to log all queries, I just want something like this:


echo $query->sql 

Thanks,

Urkman

Enable log:

http://www.yiiframework.com/doc-2.0/guide-runtime-logging.html

try this one:





$items=Client::find()

->where(['account_id' => $params['account_id']])

->prepare(Yii::$app->db->queryBuilder)->createCommand()->getSql();




the result will be: (w/o echo)

"SELECT …