当前位置: 首页>>代码示例>>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;未经允许,请勿转载。