本文整理匯總了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();
}
示例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));
}