How to tell if an update operation was successful
$Model = D('Blog'); $data['id'] = 10; $data['name'] = 'update name'; $result = $Model->save($data); if ( false !== $result ){ $this->success('Update succeeded!'); }else{ $this->error('Update failed!'); }
need to use! == false to judge whether the update is successful, because the return value of the save method is the number of records affected by the update operation. The number of records that may be affected is 0, but the update is successful.