示例#1
0
 /**
  * Insert a new object to the database - Overwrite!
  * @param  Validation $validation Validation object
  * @throws Kohana_Exception
  * @return ORM
  */
 public function create(Validation $validation = NULL)
 {
     //Hack to use the PHP date time instead of the MySQL for created
     $cols = $this->list_columns();
     // the column created exists and we didnt pass any value before
     if (isset($cols['created']) and !array_key_exists('created', $this->_changed)) {
         //add the value, forcing it so wont use the DB default ;)
         $this->set('created', Date::unix2mysql());
     }
     return parent::create($validation);
 }
 /**
  * wrapper for create
  * 
  * @param Validation $validation
  * @return ORM
  */
 public function create(Validation $validation = NULL)
 {
     // hook
     Event::raise($this, Event::BEFORE_CREATE, array('model' => $this));
     // create
     $result = parent::create($validation);
     // hook
     Event::raise($this, Event::AFTER_CREATE, array('model' => $this));
     //return orm
     return $result;
 }
示例#3
0
 /**
  * Callbacks
  */
 public function create(Validation $validation = NULL)
 {
     $this->before_save();
     $this->before_create();
     parent::create($validation);
     $this->update_count();
     $this->after_create();
     $this->after_save();
     return $this;
 }
示例#4
0
文件: orm.php 项目: ZerGabriel/cms-1
 /**
  * Updates a single record or multiple records
  *
  * @chainable
  * @param  Validation $validation Validation object
  * @throws Kohana_Exception
  * @return ORM
  */
 public function create(Validation $validation = NULL)
 {
     if (!$this->before_save()) {
         return FALSE;
     }
     if (!$this->before_create()) {
         return FALSE;
     }
     parent::create($validation);
     $this->after_create();
     $this->after_save();
     return $this;
 }
示例#5
0
 /**
  * Insert a new object to the database
  *
  * @chainable
  * @param  Validation $validation Validation object
  * @return ORM
  */
 public function create(Validation $validation = NULL)
 {
     try {
         parent::create($validation);
         $this->_update_foreign_fields();
     } catch (Kohana_Exception $e) {
         throw $e;
     }
     return $this;
 }