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


PHP ContentModel::get_model_identify_by_id方法代码示例

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


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

示例1: get_archive_by_id

 /**
  * 根据content_archives_id获取文档
  * @param mixed $content_archives_id    文档编号
  * @return string $content_archives     文档
  */
 public static function get_archive_by_id($content_archives_id, $allow_cache = false)
 {
     $content_archives_name = '';
     if (!$content_archives_id) {
         return '';
     }
     //有开启缓存功能,则从缓存中取数据, 如果有数据,则直接返回结果
     if ($allow_cache && Yii::app()->cache) {
         $_cache_key = 'content.archive.row.' . $content_archives_id;
         $_r = Yii::app()->cache->get($_cache_key);
         if ($_r && is_array($_r)) {
             return $_r;
         }
     }
     $cmd = Yii::app()->db->createCommand();
     $cmd->select('a.content_archives_id, ac.content_model_id, m.content_model_name, ac.class_id, ac.class_name, a.content_archives_subject, a.content_archives_color, a.content_archives_short_subject, a.content_archives_flag, a.content_archives_jump_url, a.content_archives_source, a.content_archives_author, a.content_archives_thumb, a.content_archives_keywords, a.content_archives_summary, a.content_archives_status, a.content_archives_rank, a.content_archives_pubtime, a.content_archives_lasttime, a.content_archives_dateline')->from('{{content_archives}} a')->join('{{content_archives_classes_relating}} acr', 'acr.content_archives_id=a.content_archives_id')->join('{{content_archives_classes}} ac', 'ac.class_id=acr.class_id')->join('{{content_model}} m', 'm.content_model_id=ac.content_model_id')->where('a.content_archives_id=:content_archives_id', array('content_archives_id' => $content_archives_id));
     $_r = $cmd->queryRow();
     if ($_r) {
         //附加表结构
         $_r['content_model_colums'] = ContentModel::get_model_table_by_id($_r['content_model_id']);
         //附加表数据
         $content_model_identify = ContentModel::get_model_identify_by_id($_r['content_model_id']);
         $_sql = "SELECT * FROM {{content_addons{$content_model_identify}}} WHERE content_archives_id=:content_archives_id LIMIT 0, 1";
         $cmd = Yii::app()->db->createCommand($_sql);
         $cmd->bindValue(':content_archives_id', $content_archives_id);
         $_a_r = $cmd->queryRow();
         if (is_array($_a_r)) {
             //
             foreach ($_r['content_model_colums'] as $_k => $_v) {
                 if ($_v['content_model_field_type'] == ContentModelField::DATA_TYPE_CHECKBOX) {
                     $_a_r[$_v['content_model_field_identify']] = unserialize($_a_r[$_v['content_model_field_identify']]);
                 }
             }
             $_r = array_merge($_r, $_a_r);
         }
         unset($_a_r);
         //自定义属性
         $_r['content_archives_flag'] = explode(',', $_r['content_archives_flag']);
         //文档栏目
         $_sql = "SELECT c.*\n\t\t\t\t\tFROM {{content_archives_classes_relating}} cr\n\t\t\t\t\tINNER JOIN {{content_archives_classes}} c ON c.class_id = cr.class_id \n\t\t\t\t\tWHERE cr.content_archives_id=:content_archives_id";
         $_r['content_archives_classes'] = Yii::app()->db->createCommand($_sql)->queryAll(true, array(':content_archives_id' => $content_archives_id));
         //文档标签
         $_sql = "SELECT tags_id, tags_name\n\t\t\t\t\tFROM {{content_archives_tags}}\n\t\t\t\t\tWHERE content_archives_id=:content_archives_id\n\t\t\t\t\tORDER BY tags_id ASC";
         $_r['content_archives_tags'] = Yii::app()->db->createCommand($_sql)->queryAll(true, array(':content_archives_id' => $content_archives_id));
     }
     //有开启缓存,则把结果添加到缓存中
     if ($allow_cache && Yii::app()->cache) {
         $_cache_time_out = Setting::getSettingCache('GOODS_ROW_TIME_OUT');
         Yii::app()->cache->set($_cache_key, $_r, $_cache_time_out);
         unset($_cache_time_out, $_cache_key);
     }
     return $_r ? $_r : array();
 }
开发者ID:nbaiwan,项目名称:yav,代码行数:58,代码来源:ContentArchives.php

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