I would like to convert the active record query of yii2 to raw SQL equivalent to check if the query is working correctly or not.
It is easy to convert the Eloquent ORM of laravel to raw SQL using toSql()
method
https://laravel.com/api/8.x/Illuminate/Database/Query/Builder.html#method_toSql
Is there any way to achieve this result in yii2, as I can only find the solutions from raw SQL to active record implementation.
If the question is still not clear will add the example for further explaination.
Yes, you can use either the property sql or the method rawSql() of the
query->command
, for example:If you are just debugging, it is probably easier to see the query on the debug toolbar.