Advertisement
susilolabs

Contoh beforeSave Yii1

Sep 23rd, 2016
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. class User extends CActiveRecord
  2. {
  3.     public static function model($className=__CLASS__)
  4.     {
  5.         return parent::model($className);
  6.     }
  7.  
  8.     public function tableName()
  9.     {
  10.         return 'user';
  11.     }
  12.  
  13.     protected function beforeSave() {
  14.         if(parent::beforeSave()) {
  15.             // letakkan pengecekan di sini.
  16.             if($checkOk)
  17.                 return true; // simpan
  18.             else
  19.                 return false; // gagalkan penyimpanan
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement