thanks grant.
i guess the findby name function doesn't work how i thought it did. i
used findAll instead and, along with your suggestion for $this->id=
$row['Modelname']['id'] everything seems to work well. updateAll()
seems like an even better solution, but i can't seem to get it to
work. i get an sql error from cake. i tried rooting around in the API
for information about updateAll but can't find anything.

thanks again,
dave


On Jul 6, 4:58 pm, Grant Cox <[EMAIL PROTECTED]> wrote:
> 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 cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to