Created
May 14, 2013 01:48
-
-
Save ryross/5573031 to your computer and use it in GitHub Desktop.
extended orm class to auto save created & updated datetimes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ORM extends Kohana_ORM { | |
public function create(Validation $validation = NULL) { | |
if (isset($this->_table_columns['created_at'])) { | |
$this->created_at = date('Y-m-d H:i:s'); | |
} | |
if (isset($this->_table_columns['updated_at'])) { | |
$this->updated_at = date('Y-m-d H:i:s'); | |
} | |
return parent::create($validation); | |
} | |
public function update(Validation $validation = NULL) { | |
if (isset($this->_table_columns['updated_at'])) { | |
$this->updated_at = date('Y-m-d H:i:s'); | |
} | |
return parent::update($validation); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment