当前位置: 首页>>代码示例>>PHP>>正文


PHP Portfolio::deleteAll方法代码示例

本文整理汇总了PHP中Portfolio::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Portfolio::deleteAll方法的具体用法?PHP Portfolio::deleteAll怎么用?PHP Portfolio::deleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Portfolio的用法示例。


在下文中一共展示了Portfolio::deleteAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionUpdate

 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if ($model->occupation->templ == 'members') {
         $model->scenario = 'genre';
     }
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['Users'])) {
         if ($_POST['member'] == 0) {
             $model->name = $_POST['Users']['name'];
             Yii::app()->user->name = $model->name;
             $model->gender = $_POST['Users']['gender'];
             $model->date_birth = $_POST['year_b'] . '-' . $_POST['month_b'] . '-' . $_POST['day_b'];
             $model->birth_public = $_POST['Users']['birth_public'];
             $model->city_id = $_POST['Users']['city_id'];
             $model->email = $_POST['Users']['email'];
             $model->about = $_POST['Users']['about'];
             $model->phone = $_POST['Users']['phone'];
             $model->phone2 = $_POST['Users']['phone2'];
             $model->phone3 = $_POST['Users']['phone3'];
             if ($model->validate() && $model->save()) {
                 Yii::app()->user->setFlash('success_save', '1');
                 $this->redirect(array('index'));
             }
             /*else { 
                   echo CHtml::errorSummary($model);
                   //exit();
               }*/
         }
         if ($_POST['member'] == 1) {
             //$model->attributes=$_POST['Users'];
             if (isset($_POST['Users']['name_studio'])) {
                 $_POST['Users']['name'] = $_POST['Users']['name_studio'];
                 //unset($_POST['Users']['name_studio']);
                 $model->setScenario('studio_update');
             }
             foreach ($_POST['Users'] as $k => $v) {
                 if ($k == 'photo') {
                     if ($v != '') {
                         $model->photo = CUploadedFile::getInstance($model, 'photo');
                     }
                 } elseif ($k == 'url') {
                     $v = str_replace('http://', '', $v);
                     $model->{$k} = $v;
                 } else {
                     $model->{$k} = $v;
                 }
             }
             if (!isset($_POST['Users']['phone2'])) {
                 $model->phone2 = '';
             }
             if (!isset($_POST['Users']['phone3'])) {
                 $model->phone3 = '';
             }
             if (isset($_POST['year_b'])) {
                 $model->date_birth = $_POST['year_b'] . '-' . $_POST['month_b'] . '-' . $_POST['day_b'];
             }
             Yii::app()->user->name = $model->name;
             //echo '<pre>';
             //print_r($_POST);
             //echo '</pre>';
             //exit();
             if (isset($_POST['Users']['genre_id'])) {
                 $model->genre_id = serialize($_POST['Users']['genre_id']);
             }
             if ($model->save()) {
                 if (isset($_POST['Users']['genre_id'])) {
                     Yii::import('application.modules.my.models.Portfolio');
                     Yii::import('application.modules.my.models.Video');
                     Yii::import('application.modules.my.models.Genre');
                     $keys = array();
                     $data = '';
                     $data = Portfolio::model()->findAllByAttributes(array('uid' => Yii::app()->user->id));
                     //print_r($data); exit();
                     if (is_array($data) && !empty($data)) {
                         //Portfolio::model()->deleteAllByAttributes(array('uid'=>Yii::app()->user->id));
                         //exit();
                         foreach ($_POST['Users']['genre_id'] as $genre) {
                             $item = Portfolio::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'title' => Genre::getName($genre)));
                             if (count($item) > 0) {
                                 $keys[] = $item->id;
                             } else {
                                 $mod = new Portfolio();
                                 $mod->title = Genre::getName($genre);
                                 $mod->uid = Yii::app()->user->id;
                                 $mod->save();
                                 $keys[] = $mod->id;
                             }
                         }
                         $del = new Portfolio();
                         $criteria = new CDbCriteria();
                         $criteria->condition = 'uid=' . Yii::app()->user->id;
                         $criteria->addNotInCondition('id', $keys);
                         $del->deleteAll($criteria);
                     } else {
                         foreach ($_POST['Users']['genre_id'] as $genre) {
                             $mod = new Portfolio();
                             $mod->title = Genre::getName($genre);
                             $mod->uid = Yii::app()->user->id;
//.........这里部分代码省略.........
开发者ID:schur-maksim,项目名称:happymoments.ua,代码行数:101,代码来源:ProfileController.php


注:本文中的Portfolio::deleteAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。