I want to print query:
$demo = Demo::find()->all();
I want to see converted SQL query with parameters:
createCommand()->getRawSql();
is showing me an error message:
yii2 Call to a member function createCommand() on a non-object
Please help me to see the actual SQL query.
returns an array of all models not the actual sql.
if you want the sql use this (this is the sql which is excecuted)
Eg:
A simple way is use the Active Query Builder createCommand method
see this for refernce http://www.yiiframework.com/doc-2.0/yii-db-activequery.html and http://www.yiiframework.com/doc-2.0/yii-db-activequery.html#createCommand()-detail
Hiii Paritosh,
You can view the query that is being executed in SQl format by
yii\db\Connection::createCommand()
objects like