The query builder that comes with Yii is very easy to use. It saves the process of spelling sql. I encountered such a problem when writing a statement today
Use $operate_rst to record the operation results. There is no problem when executing a new insert. However, when updating, sometimes it will show that the operation failed. After checking for a long time, I can't find the reason, so I have to read the document
http://www.yiiframework.com/doc/api/1.1/CDbCommand#update-detail
When you see the return item, it is
I immediately understood the problem, because sometimes the data may not be changed but the update operation is triggered, so the number of rows changed at this time is 0, and the returned judgment will enter the error code. .
Similarly, the meaning of the return value of delete() and insert() methods is also the number of affected rows, so delete and insert can judge whether the operation is successful based on whether the return value is greater than 0, but the update operation is not necessarily the return value. A value of 0 may also indicate that the DB operation was successful.