Monday, January 30, 2012

Re: not updating modified, how ?

Hi again,

thanks to your tips, I effectively missed an example. This one worked :

Change this line:
$this->request->data['modified'] = false;
to:
$this->request->data['Device']['modified'] = false;
also make sure you don't forget those fields in your whitelist array then (which you seem to have)
Wasn't needed, as I don't updated "modified".

Thanks all and best regards,
Charles


On 28.1.2012 22:37 , Charles Bueche wrote:
Hey bakers,

I'm using CakePHP 2.1 on Ubuntu.

I'm trying to update a single DB field, without CakePHP updating the "modified" field. Here is my code:

            $this->Device->id = $device_id;
            $this->request->data['Device']['last_seen'] = date("Y-m-d H:i:s");
            $this->request->data['modified'] = false;
            $this->Device->save($this->request->data, array('fieldList' => array( 'last_seen')));

However, "modified" gets an update. In http://book.cakephp.org/2.0/en/models/saving-your-data.html, there is a tip saying " If you don’t want the updated field to be updated when saving some data add 'updated' => false to your $data array".

I tried 'updated' => false and 'modified' => false, but "modified" always gets an update. Any idea how I can avoid this ?

TIA,
Charles
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: