diff options
author | Evan Prodromou <evan@status.net> | 2010-01-28 12:57:52 -0500 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-01-28 13:54:01 -0500 |
commit | 84b5480007d30280cc9c829fe1316db0f853f64c (patch) | |
tree | 960a9f411425a12fe2c85f2c3318bc5f8dce4b0e | |
parent | c81318d3ca60f47b3e248c64b7c27364a24814a7 (diff) |
update mysqltimestamps on insert and update
-rw-r--r-- | classes/Memcached_DataObject.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index 2cc6377f8..bc9aaf81f 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -147,6 +147,7 @@ class Memcached_DataObject extends DB_DataObject { $result = parent::insert(); if ($result) { + $this->fixupTimestamps(); $this->encache(); // in case of cached negative lookups } return $result; @@ -159,6 +160,7 @@ class Memcached_DataObject extends DB_DataObject } $result = parent::update($orig); if ($result) { + $this->fixupTimestamps(); $this->encache(); } return $result; @@ -366,7 +368,7 @@ class Memcached_DataObject extends DB_DataObject } /** - * sends query to database - this is the private one that must work + * sends query to database - this is the private one that must work * - internal functions use this rather than $this->query() * * Overridden to do logging. @@ -529,4 +531,20 @@ class Memcached_DataObject extends DB_DataObject return $c->delete($cacheKey); } + + function fixupTimestamps() + { + // Fake up timestamp columns + $columns = $this->table(); + foreach ($columns as $name => $type) { + if ($type & DB_DATAOBJECT_MYSQLTIMESTAMP) { + $this->$name = common_sql_now(); + } + } + } + + function debugDump() + { + common_debug("debugDump: " . common_log_objstring($this)); + } } |