我对CakePHP很新,并且遇到了问题。我尝试使用以下方法连续更新一个字段:
$options = array('conditions' => array('User.id' => $_POST['userid']));
$user = $this->User->find('first', $options);
$currentpoint = $user['User']['point'];
$correctanswerpoint = Configure::read('CORRECT_SYSTEMANSWER_POINT');
$newpoint = $currentpoint + $correctanswerpoint;
$this->User->updateAll(array('User.point'=>$newpoint), array('User.id'=>$_POST['userid']));
没有错误,但是字段点(bigint(20))没有更新。我已经更改了字段以更新到同一行中的另一个字段,这是一个smallint类型,并且更新很顺利。
我的调试日志似乎表明SQL查询也可以:
[query] => UPDATE `askyoode_askyoo`.`users` AS `User` LEFT JOIN `askyoode_askyoo`.`countries` AS `Country` ON (`User`.`country_id` = `Country`.`id`) LEFT JOIN `askyoode_askyoo`.`accesstypes` AS `Accesstype` ON (`User`.`accesstype_id` = `Accesstype`.`id`) SET `User`.`point` = 57 WHERE `User`.`id` = 124
[params] => Array
(
)
[affected] => 1
[numRows] => 1
[took] => 12
)
在MySQL中手动运行相同的SQL语句。为了解决这个问题,一整天都在撕扯我的头发。任何帮助是极大的赞赏。谢谢!