我正在尝试更新数据库中一个字段中的多条记录。出于某种原因,我不断收到 SQL 错误:1054:“字段列表”中的未知列“520947b9”。502947B9 是我 ID 的一部分。我不明白为什么该值被视为字段列表。这是我的代码。也就是说,我不确定我是否正确更新了这些记录。如果我不是,请向我指出。谢谢!!
public function findPolicyIds($coverageId = null) {
$policyid = $this->Policy->find('all', array(
'recursive' => -1,
'conditions' => array('Policy.coverage_id' => $coverageId),
'fields' => array('Policy.id')));
foreach($policyid as $id) {
$all[] = $id['Policy']['id'];
foreach ($all as $key) {
$this->Policy->Declination->updateAll(
array('Declination.policy_id' => $key),
array('Declination.coverage_id <=' => $coverageId)
);
}
}
}
这是我的错误
查询: UPDATE declinations
AS Declination
LEFT JOIN policies
AS Policy
ON ( Declination
. policy_id
= Policy
. id
) SET Declination
。policy_id
= 520947b9-0210-4067-94ea-70f8ae78509d 哪里Declination
。coverage_id
<= '520947b9-1fa0-45db-992e-70f8ae78509d'
查询: UPDATE declinations
AS Declination
LEFT JOIN policies
AS Policy
ON ( Declination
. policy_id
= Policy
. id
) SET Declination
。policy_id
= 520947b9-0694-4724-b353-70f8ae78509d 哪里Declination
。coverage_id
<= '520947b9-1fa0-45db-992e-70f8ae78509d'