Dao Statement Not Updating Mysql

Hello eveyrone,

I’ve been updating one of my apps with the current version of Yii and am having problems with an update routine that takes user content and updates the database table accordingly. It basically does no update but doesn’t cause any errors. The result is returned as 0. I’m not sure what is wrong with it so hopefully someone can see the error.

Here is the piece of code that performs update.

 return Yii::app()->db->createCommand("UPDATE narratives SET description = '$this->description', content = '$this->content' WHERE id = '$this->id'")->execute();

Try some basic debugging tasks:

Output the variables used in the statement and see if they are filled correctly.



Then also try to execute the statement direct on the db via phpMyAdmin for example.

Further you can set enableParamLogging to true and use yii’s log mechanism to see db queries in logfiles, etc.

You can also use firebug to see db queries: SQL Logging and Profiling in Firebug

Thanks for your reply. It was something totally different in my validation causing the problem.