Yii2 – Output the SQL from a query builder

Dump the Sql for a Query

Here’s a quick tip to dump the SQL for query.

 

    $query = new Books::find()->where('author=2');
    echo $query->createCommand()->sql;

There we go!

Let’s Start a Project!

Contact Me