when i update data use the method update of CDbCommand, the return type of this method is integer ,
so maybe the result is 0 or >0 ,now how can i check the result is success or fail .
when i update data use the method update of CDbCommand, the return type of this method is integer ,
so maybe the result is 0 or >0 ,now how can i check the result is success or fail .
The result is the number of rows affected by the update (see here).
You can treat this as a boolean if you like:
$success = $command->update();
If something goes wrong with the update at a database level (like a constraint being violated), a CDbException will be thrown, so you should wrap your code in a try block to account for this.
thank you !
if I treat $success as a boolean ,the value is 1 frist time, second time is 0 ,so I can’t use
if($success) to check the result simply .