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