为什么多条记录没有使用cakephp进行更新?

时间:2014-03-11 12:35:06

标签: cakephp-2.0

我在下面给出了我的控制器代码:

for ($i = 0; $i < count($club_open); $i++) {
    $infomation["ClubOpenDay"]["club_id"] = $club_id;
    $infomation["ClubOpenDay"]["days"] = $club_open[$alpha[$i]];
    $infomation["ClubOpenDay"]["open_time"] = $club_open_time[$alpha[$i]];
    $infomation["ClubOpenDay"]["close_time"] = $club_close_time[$alpha[$i]];
    $infomation["ClubOpenDay"]["status"] = $club_status[$alpha[$i]];
    $this->ClubOpenDay->updateAll(
      array('ClubOpenDay.status' => "'".$infomation["ClubOpenDay"]["status"]."'"),
      array('ClubOpenDay.club_id' => "'".$club_id."'")
    );
}

使用此代码,我无法更新多条记录。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

而不是:

$this->ClubOpenDay->updateAll(
  array('ClubOpenDay.status' => "'".$infomation["ClubOpenDay"]["status"]."'"),
  array('ClubOpenDay.club_id' => "'".$club_id."'")
);

写下以下内容:

$this->ClubOpenDay->updateAll(
  array('ClubOpenDay.status' => $infomation["ClubOpenDay"]["status"]),
  array('ClubOpenDay.club_id' => $club_id)
);