1. Use updateAll()
$this->updateAll( array('printed'=>'Y'), array('printed'=>'N') );
2. Are you sure that "findByPrinted" will return an array of data
without your model key? I would have thought you want
function updatePrintStatus(){
$ret = $this->findByPrinted('N');
foreach($ret as $row){
$this->id = $row['YourModel']['id'];
$this->save(array('printed'=>'Y'));
}
}
3. If that doesn't work, try saving with the id too
$this->save(array('printed'=>'Y','id'=>$row['YourModel']['id']));
On Jul 7, 6:42 am, "Dave M." <[EMAIL PROTECTED]> wrote:
> Hi all,
> For some reason I cannot get this to work, but I know there is
> something simple I am overlooking.
>
> I have a function in my model which should find all records with a
> certain criteria (in this case, those records whose 'printed' field is
> 'N') and then update those records (changing 'printed' to 'Y'). The
> code I have been trying is below. What is happening is that only the
> first record is updated. I though unsetting the id would solve that
> problem, but it does not.
>
> function updatePrintStatus(){
> $ret = $this->findByPrinted('N');
> foreach($ret as $row){
> $this->id = $row['id'];
> $this->save(array('printed'=>'Y'));
> unset($this->id);
> }
>
> }
>
> Any thoughts?
>
> thanks,
> dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---