$sql = "UPDATE countries SET city_id=:city_id WHERE id =:id";
$command = Yii::app()->db->createCommand($sql);
$command->bindParam(":id", 5, PDO::PARAM_INT);
$command->bindParam(":city_id", 439, PDO::PARAM_INT);
$command->execute();
I need a way display the rendered query, for example:
echo $command->getQuery();
//shows: UPDATE countries SET city_id=439 WHERE id=5
[b]Please be careful when posting, you will get more and better answers.
You’re not suggesting to add a new feature to Yii, so this topic should not be in the “Feature Requests” forum.
This kind of question should be in "General Discussion for Yii 1.1.x".
[/b]
If you want to use PDO, then a Yii forum is not the best place. Read the doc or find a generic PHP forum.
Read the API of CDbCommand (the class of your $command). I believe $command->getText() could be useful.
Have a look at the extension yii-debug-toolbar, it may be what you’re looking for.
IIRC, it is possible but hard with mere PDO. Yii emulates prepares by default, so the parameters values should appear in the logs and in ::getText(), though I didn’t test it.
To me, this looks like a call for help. That’s totally okay, but it’s not a feature request. And in fact, the feature already exists, you just did not know about it.
If you were really requesting a feature, then sorry for blaming you. But please be cautious next time because your text wasn’t clear at all, and you should have asked somewhere else if the featured existed before requesting it is added to Yii.