當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CActiveRecord::beforeSave方法代碼示例

本文整理匯總了PHP中CActiveRecord::beforeSave方法的典型用法代碼示例。如果您正苦於以下問題:PHP CActiveRecord::beforeSave方法的具體用法?PHP CActiveRecord::beforeSave怎麽用?PHP CActiveRecord::beforeSave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CActiveRecord的用法示例。


在下文中一共展示了CActiveRecord::beforeSave方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: beforeSave

 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->id_empresa = Yii::app()->user->model->id_empresa;
     }
     return parent::beforeSave();
 }
開發者ID:hccresende,項目名稱:FlyManager,代碼行數:7,代碼來源:Aviao.php

示例2: beforeSave

 public function beforeSave()
 {
     parent::beforeSave();
     $picture = CUploadedFile::getInstance($this, 'image');
     if ($picture) {
         $imagename = $picture->getTempName();
         $image = Yii::app()->image->load($imagename);
         if ($image) {
             if ($this->avatar) {
                 unlink($_SERVER['DOCUMENT_ROOT'] . $this->avatar_folder . '/' . $this->avatar);
             }
             if ($image->width >= $image->height) {
                 $image->resize(20000, 93)->rotate(0)->quality(90)->sharpen(20);
             } else {
                 $image->resize(93, 20000)->rotate(0)->quality(90)->sharpen(20);
             }
             $image->crop(93, 93);
             $file_name = rand() . '.' . $picture->extensionName;
             $savename = $_SERVER['DOCUMENT_ROOT'] . $this->avatar_folder . '/' . $file_name;
             $image->save($savename);
             $this->avatar = $file_name;
         }
     }
     return true;
 }
開發者ID:snipesn,項目名稱:UkrYama-2,代碼行數:25,代碼來源:Profile.php

示例3: beforeSave

 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->datahora_insercao = new CDbExpression('NOW()');
     }
     return parent::beforeSave();
 }
開發者ID:bgstation,項目名稱:erp,代碼行數:7,代碼來源:LogItemNaoCadastrado.php

示例4: beforeSave

 protected function beforeSave()
 {
     if (substr($this->url, 0, strlen('http')) !== 'http') {
         $this->url = "http://" . $this->url;
     }
     return parent::beforeSave();
 }
開發者ID:stan5621,項目名稱:eduwind,代碼行數:7,代碼來源:FriendLink.php

示例5: beforeSave

 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         $this->userId = Yii::app()->user->userId;
     }
     return true;
 }
開發者ID:tiger2soft,項目名稱:travelman,代碼行數:7,代碼來源:PlanComment.php

示例6: beforeSave

 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if ($this->album_id == 0) {
             $this->album_id = null;
         }
         if ($this->isNewRecord) {
             $this->click = 0;
             $this->add_uid = Yii::app()->user->id;
             $this->add_time = time();
             if ($this->url == "") {
                 if ($this->musicfile) {
                     $name = $this->musicfile->name;
                     $this->url = $name;
                 }
             }
         } else {
             if ($this->musicfile) {
                 $name = $this->musicfile->name;
                 $this->url = $name;
             }
         }
         return true;
     } else {
         return false;
     }
 }
開發者ID:robebeye,項目名稱:MusicDream,代碼行數:27,代碼來源:Music.php

示例7: beforeSave

 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->position = count(Components::model()->findAll("projectId = {$this->projectId}")) + 1;
     }
     return parent::beforeSave();
 }
開發者ID:Romandre90,項目名稱:vectortraveler,代碼行數:7,代碼來源:Components.php

示例8: beforeSave

 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         $this->spotNum++;
     }
     return true;
 }
開發者ID:tiger2soft,項目名稱:travelman,代碼行數:7,代碼來源:Guide.php

示例9: beforeSave

 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->created = date('Y/m/d H:i:s');
     }
     return parent::beforeSave();
 }
開發者ID:barricade86,項目名稱:raui,代碼行數:7,代碼來源:ApartmentXMLFeed.php

示例10: beforeSave

 protected function beforeSave()
 {
     if (!parent::beforeSave()) {
         return false;
     }
     if (($this->scenario == 'insert' || $this->scenario == 'update') && ($this->icon = CUploadedFile::getInstance($this, 'icon'))) {
         // Если обновляем запись, то удаляем прошлую фотографию
         if ($this->scenario == 'update') {
             $file = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/' . $this->img;
             $fileMini = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/mini-' . $this->img;
             if (file_exists($file) and $this->img != '') {
                 unlink($file);
             }
             if (file_exists($fileMini) and $this->img != '') {
                 unlink($fileMini);
             }
         }
         $fileName = mktime(date("i")) . '.jpg';
         $this->img = $fileName;
         $file = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/' . $fileName;
         $this->icon->saveAs($file);
         //Делаем ресайз только что загруженному изображению
         $Image = Image::factory("./Image/Project/" . $fileName);
         if ($Image->width >= $Image->height) {
             $Image->resize(375, 410, Image::WIDTH)->crop(375, 410, "top", "center");
             $Image->save($_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/mini-' . $fileName);
         } else {
             $Image->resize(235, 314, Image::HEIGHT)->crop(235, 314, "top", "center");
             $Image->save($_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/mini-' . $fileName);
         }
     }
     return true;
 }
開發者ID:WorkAxiles89,項目名稱:Construction,代碼行數:33,代碼來源:Project.php

示例11: beforeSave

 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->created = time();
     }
     return parent::beforeSave();
 }
開發者ID:aantonw,項目名稱:dcourier.system,代碼行數:7,代碼來源:ApiAccesslist.php

示例12: beforeSave

 public function beforeSave()
 {
     if (isset($_POST['items'])) {
         $this->modulos = join(',', $_POST['items']);
     }
     return parent::beforeSave();
 }
開發者ID:rusli-nasir,項目名稱:smsempresayii,代碼行數:7,代碼來源:Rol.php

示例13: beforeSave

 public function beforeSave()
 {
     //if (strpos($this->nombre,'@')!==false){
     $this->nombre = '@' . strtolower(trim($this->nombre, '@'));
     //}
     return parent::beforeSave();
 }
開發者ID:rusli-nasir,項目名稱:smsempresayii,代碼行數:7,代碼來源:Variable.php

示例14: beforeSave

 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->status = self::STATUS_OK;
     }
     return parent::beforeSave();
 }
開發者ID:stan5621,項目名稱:jp_edu_online,代碼行數:7,代碼來源:CourseMember.php

示例15: beforeSave

 public function beforeSave()
 {
     if ($this->isNewRecord)
         $this->creation_date = new CDbExpression('NOW()');
     
     return parent::beforeSave();
 }
開發者ID:alur86,項目名稱:PHP_Code_Samples,代碼行數:7,代碼來源:RecoveryPassword.php


注:本文中的CActiveRecord::beforeSave方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。