Wednesday, August 14, 2013

Saved Indexed Array/UpdateAll

I am trying to figure out how I should go about updating multiple records for one field. For some reason my updateall method is not recognizing my variable as a string. That said, the variable I am trying to use is an indexed array. I started by trying to use implode function, and converting the array to a string but Im not sure if you can loop through that comma separated string and save each record. Here is what Ive tried 


    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)
);
}
 
}
}



That said, Im trying to save records in Declinations.Policy_Id field for each record that has the same CoverageId that is being passed in. What am I doing wrong?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate