I am trying to update multiple records in one field in my database. For some reason I keep getting SQL Error: 1054: Unknown column '520947b9' in 'field list'. 502947B9 is apart of my ID. Im not understanding why that value is being seen as a field list. Here is my code. That said, Im not sure Im updating these records correctly. If Im not please point it out to me. Thanks!!
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)
);
}
}
}
Here are my errors
Query: UPDATE declinations
AS Declination
LEFT JOIN policies
AS Policy
ON (Declination
.policy_id
= Policy
.id
) SET Declination
.policy_id
= 520947b9-0210-4067-94ea-70f8ae78509d WHERE Declination
.coverage_id
<= '520947b9-1fa0-45db-992e-70f8ae78509d'
Query: UPDATE declinations
AS Declination
LEFT JOIN policies
AS Policy
ON (Declination
.policy_id
= Policy
.id
) SET Declination
.policy_id
= 520947b9-0694-4724-b353-70f8ae78509d WHERE Declination
.coverage_id
<= '520947b9-1fa0-45db-992e-70f8ae78509d'