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


PHP ContentModel::alter_addons_table方法代碼示例

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


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

示例1: actionUpdate

 public function actionUpdate($content_model_id, $id, $page = null)
 {
     $field = ContentModelField::get_field_by_id($id, false);
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (!isset($_POST['Field']) || !is_array($_POST['Field'])) {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('保存模型字段信息錯誤', self::MSG_ERROR, true);
         }
         if ($_POST['Field']['content_model_field_name'] == '') {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('字段名稱不能為空', self::MSG_ERROR, true);
         }
         /*if($_POST['Field']['content_model_field_identify'] =='') {
         			$this->redirect[] = array(
         				'text' => '',
         				'href' => 'javascript:history.go(-1);',
         			);
         			$this->message('字段標識不能為空', self::MSG_ERROR, true);
         		}
         		
         		if(!preg_match("/^[\w]+$/",$_POST['Field']['content_model_field_identify'])) {
         			$this->redirect[] = array(
         				'text' => '',
         				'href' => 'javascript:history.go(-1);',
         			);
         			$this->message('字段標識隻能為英文字母', self::MSG_ERROR, true);
         		}*/
         if (!isset($_POST['Field']['content_model_field_type']) || $_POST['Field']['content_model_field_type'] == '') {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('請選擇字段數據類型', self::MSG_ERROR, true);
         }
         if (intval($_POST['Field']['content_model_field_max_length']) < 1) {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('字段最大長度格式錯誤,請填寫大於0的數字', self::MSG_ERROR, true);
         }
         /*$content_model_field = ContentModelField::get_field_by_id($id);
         		$sql = "SELECT `content_model_field_identify` FROM {{content_model_fields}}
         				WHERE content_model_field_id<>:content_model_field_id AND `content_model_field_status`<>:content_model_field_status AND content_model_field_identify=:content_model_field_identify  AND `content_model_id`=:content_model_id";
         		$cmd = Yii::app()->db->createCommand($sql);
         		$cmd->bindValue(':content_model_field_id', $id);
         		$cmd->bindValue(':content_model_field_status', ContentModelField::STAT_DELETED);
         		$cmd->bindValue(':content_model_field_identify', $_POST['Field']['content_model_field_identify']);
         		$cmd->bindValue(':content_model_id', $content_model_id);
         		$cmd->execute();
         		
         		if($cmd->queryScalar()) {
         			$this->redirect[] = array(
         				'text' => '',
         				'href' => 'javascript:history.go(-1);',
         			);
         			$this->message('字段標識重複', self::MSG_ERROR, true);
         		}*/
         $flag = Yii::app()->db->createCommand()->update('{{content_model_fields}}', array('content_model_field_name' => $_POST['Field']['content_model_field_name'], 'content_model_field_type' => isset($_POST['Field']['content_model_field_type']) ? intval($_POST['Field']['content_model_field_type']) : 0, 'content_model_field_default' => $_POST['Field']['content_model_field_default'], 'content_model_field_tips' => $_POST['Field']['content_model_field_tips'], 'content_model_field_max_length' => isset($_POST['Field']['content_model_field_max_length']) ? intval($_POST['Field']['content_model_field_max_length']) : 1, 'content_model_field_rank' => !empty($_POST['Field']['content_model_field_rank']) ? intval($_POST['Field']['content_model_field_rank']) : 255, 'content_model_field_lasttime' => $_SERVER['REQUEST_TIME']), 'content_model_field_id=:content_model_field_id', array(':content_model_field_id' => $id));
         //
         if ($flag) {
             //更新緩存
             ContentModelField::update_cache();
             $content_model_identify = ContentModel::get_model_identify_by_id($content_model_id);
             $newfields = array(array('field_name' => $_POST['Field']['content_model_field_name'], 'field_identify' => $field['content_model_field_identify'], 'field_type' => $_POST['Field']['content_model_field_type'], 'field_length' => $_POST['Field']['content_model_field_max_length']));
             if (ContentModel::alter_addons_table($content_model_identify, $newfields)) {
                 //更新附加表成功
             } else {
                 //更新附加表失敗
             }
             //記錄操作日誌
             $user = Yii::app()->user;
             $message = '{user_name}修改內容模型字段({field_name})信息成功';
             $data = array('user_id' => $user->id, 'user_name' => $user->name, 'field_name' => $field['content_model_field_name'], 'data' => array('content_model_field_id' => $id));
             AdminLogs::add($user->id, 'Content/Model/Field', $id, 'Modify', 'success', $message, $data);
         }
         if (!isset($_GET['ajax'])) {
             $this->redirect[] = array('text' => '', 'href' => url($this->module->id . "/Content/Model/{$content_model_id}/Field/Index"));
             $this->message('修改模型字段完成', self::MSG_SUCCESS, true);
         }
     }
     if (empty($field)) {
         $this->redirect[] = array('text' => '', 'href' => url($this->module->id . "/Collect/Model/{$content_model_id}/Field/Index"));
         $this->message('模型字段不存在或已被刪除', self::MSG_ERROR, true);
     }
     $this->render('update', array('field' => $field, "content_model_id" => $content_model_id));
 }
開發者ID:nbaiwan,項目名稱:yav,代碼行數:81,代碼來源:FieldController.php


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