The query builder that comes with Yii is very easy to use and saves you the process of spelling out SQL. I encountered this problem when writing a statement:
Use $operate_rst to record the operation results. There is no problem in executing the new insert, but when updating, sometimes it will show that the operation failed. , I checked for a long time and couldn’t find the reason, so I had to look through the documents. http://www.yiiframework.com/doc/api/1.1/CDbCommand#update-detail See the return item: {return} integer number of rows affected by the execution. Sometimes the data may not be changed but an update operation is triggered, so the number of changed rows at this time is 0, and the returned judgment will enter the error code. In the same way, 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, and the return value is 0. It may indicate that the DB operation was successful. |