How to get SQL query as text in Yii2

How to get SQL query as text in Yii2

It would seem a simple and trivial task. But I had to dig a little into the code and docs.
And so, to get a "clean" SQL query that will subsequently be transferred to the DB for execution, it is enough to use the following code:

echo $Query -> select('*')
-> from('{{%authitem}}') -> createCommand() -> getRawSql();
Posts on similar topics

Are you having problems with your Yii2 framework website? Do you need additional functionality?
>Then write to me via the feedback form, and I will try to help you.

Write a comment

Your email address will not be published. Required fields are marked *