Skip to content

Instantly share code, notes, and snippets.

@ryross
Created May 14, 2013 01:48
Show Gist options
  • Save ryross/5573031 to your computer and use it in GitHub Desktop.
Save ryross/5573031 to your computer and use it in GitHub Desktop.
extended orm class to auto save created & updated datetimes.
<?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