Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added beforeSave() to set created_at and updated_at accordingly

  • Loading branch information...
commit 433d238011e181c3048d85f83ed7e8858c421bcf 1 parent 2cb00b6
@knut knut authored
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/protected/models/Post.php
View
12 src/protected/models/Post.php
@@ -114,6 +114,18 @@ public function getBodyHtml() {
return $html;
}
+ protected function beforeSave() {
+ if(parent::beforeSave()) {
+ $now = date('Y-m-d H:i:s');
+ if($this->isNewRecord) {
+ $this->created_at = $now;
+ }
+ $this->updated_at = $now;
+ return true;
+ }
+ return false;
+ }
+
/*public function attributeLabels()
{
return array(
Please sign in to comment.
Something went wrong with that request. Please try again.