So, extrapolating nate's beforeSave() suggestion in the ticket
(thanks, nate!) into something that can be added to my app_model.php
file to be usable globally (and with some slight refactoring from my
initial design, making the properties simply strings instead of arrays
since I don't have to worry about backwards supporting the 'modified'
& 'updated' columns), I get this to make this behavior global to my
models:
// These can be changed in the inheriting model
// to the appropriate column name to enable the
// automagic timestamping on the desired operation
var $createField = false;
var $updateField = false;
function beforeSave() {
// Alternate column automagic timestamping support
$nowDate = date('Y-m-d H:i:s');
if ( $this->updateField ) {
$this->set($this->updateField, $nowDate);
}
if ( $this->createField and !$this->exists() ) {
$this->set($this->createField, $nowDate);
}
return true;
}
Works like a charm for db inserts/updates. Doesn't do anything for my
scaffolds, but they are just scaffolds. :)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---