Example #1
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         //$this->created = new CDbExpression('NOW()');
         // $nuevovalor=new CDbExpression('SELEC MAX(NUMERO)');
         //$this->numero=new CDbExpression('SELECt MAX(NUMERO) from mot_materiales');
         //$this->modified = new CDbExpression('NOW()');
         $this->codep = Numeromaximo::numero($this, 'codep', 'maximovalor', 3);
         //$this->codtraba='0001';
         //$this->creadorpor='0001';
     }
     return parent::beforeSave();
 }
Example #2
0
 /**
  * This method is invoked before saving a record (after validation, if any).
  * @return boolean whether the saving should be executed. Defaults to true.
  */
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if ($this->isNewRecord) {
             $this->create_time = $this->update_time = time();
             $this->author_id = Yii::app()->user->id;
         } else {
             $this->update_time = time();
         }
         return true;
     } else {
         return false;
     }
 }