Yes, you should always try to use find() instead read() to be on the safe
side here.
Am Dienstag, 11. Juni 2013 05:49:16 UTC+2 schrieb Reuben:
>
> Hi
>
> I'm having trouble with reading some data, and I think I sort why a
> particular operation is happening at a technical level, but I'm left
> wondering if it's the right behaviour.
>
> Here's what I'm doing.
>
> In one operation, I'm doing a read of a model for all fields
>
> $this->Model->read(null, $id);
>
> Then I'm constructing a new $data variable that contains the $id, and any
> changed fields. Typically, this just has a changed status field. I end up
> with :
>
> $data = array('id' => $id, 'status' => 'closed');
> $this->Model->save($data);
>
> However, when I look at the SqlLog, it would seem that all data is
> retained from the previous read, and the new data is merged with the
> existing data, and it is all saved. The side effect is that the modified
> field is not updated.
>
> Is this intentional behaviour? I thought that if you were to specify the
> primary key and data in the input of the save, then it would just save that
> data, and not data from a previous read.
>
> Should I be doing a find('first') instead of a read() to avoid this?
>
> Regards
> Reuben Helms
>
>
>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.