This tutorial show you how to dump the Sql Query from an Activerecord and more.
It can help us to debug Sql query in some case when yii debug is not work.
Example:
To get raw SQL query with all parameters included try:
It not only works with Activerecord .
It can help us to debug Sql query in some case when yii debug is not work.
Example:
$listBooks = Books::find()->where('author=2')->all();
To get raw SQL query with all parameters included try:
$query = Books::find()->where('author=2'); echo $query->createCommand()->sql; echo $query->createCommand()->getRawSql();
It not only works with Activerecord .
Refer : http://chris-backhouse.com/Yii2-Output-the-SQL-from-a-query-builder/1027