#5651: Field 'modified' can not be auto updated
---------------------------+------------------------------------------------
Reporter: hulucat | Owner:
Type: Bug | Status: reopened
Priority: Medium | Milestone: 1.2.x.x
Component: Model | Version: RC3
Severity: Normal | Resolution:
Keywords: modified | Php_version: PHP 5
Cake_version: 1.2.0.7692 |
---------------------------+------------------------------------------------
Changes (by dbennett):
* status: closed => reopened
* resolution: needmoreinfo =>
Comment:
The following case will not update 'updated' or 'modified'...
{{{
// * toggle the status of the mobile_provider between active and
inactive
function toggleStatus($id) {
$this->data=$this->MobileProvider->findById($id);
$this->data['MobileProvider']['status'] =
strtoupper($this->data['MobileProvider']['status']) == 'A'
? 'I'
: 'A';
if ($this->MobileProvider->save($this->data)) {
$this->redirect('/mobile_providers/index');
}
}
}}}
In this case the 'updated' field is read from the database during the
findById call. Since the field is present in the data set that is sent to
the AppModel save() method it is not set to the new value. As a work-
around, I am using the PHP function unset() to remove the 'updated' field
from the data set before the call to save:
{{{
// * toggle the status of the mobile_provider between active and
inactive
function toggleStatus($id) {
$this->data=$this->MobileProvider->findById($id);
$this->data['MobileProvider']['status'] =
strtoupper($this->data['MobileProvider']['status']) == 'A'
? 'I'
: 'A';
// work-around, unset the updated field to insure that it
// is set to the current date
unset($this->data['MobileProvider']['updated']);
if ($this->MobileProvider->save($this->data)) {
$this->redirect('/mobile_providers/index');
}
}
}}}
--
Ticket URL: <https://trac.cakephp.org/ticket/5651#comment:4>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" 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/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---