I am using Yii Yii :: app () -> db-> createCommand () to create an SQL query. To view the SQL code that Yii generates, I use the getText () method for CDBCommand. The problem is that I am using the getText () method for an SQL code that contains parameters, for example:
Yii::app()->db->createCommand() ->select("name") ->from('package') ->where('id=:id', array(':id'=>5)) ->queryRow();
The getText () method returns the following SQL:
select name from package where id=:id
instead:
select name from package where id=5
This is good for simple queries, but for more complex queries with a large number of parameters, it is rather painful to copy / paste each parameter into the SQL code to check it.
Is there a way to show parameters directly inside SQL using getText () or some other method in Yii?
Hooray!
Bug magnet
source share