|
楼主 |
发表于 2015-9-1 08:51:57
|
显示全部楼层
PHP复制代码 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class About_model extends CI_Model
{
const article = 'article'; // 文章
const category = 'article_category'; // 文章分类
const announcement = 'announcement'; // 公告
/**
* 获取内容详情
*
* @access public
* @return array
*/
public function get_detail_info ()
{
$data = $temp = array();
$temp['type'] = $this->input->get('type', TRUE);
$temp['id'] = (int )$this->input->get('id');
if( ! empty($temp['type']) && ! empty($temp['id']))
{
$temp['table'] = ($temp['type'] != 'announcement') ? self::article : self::announcement;
$temp['where'] = array('where' => array('id' => $temp['id']));
$data = $this->c->get_row($temp['table'], $temp['where']);
$data['act'] = $temp['type'];
$data['name'] = ($temp['type'] != 'announcement') ? '文章详情' : '公告详情';
}
unset($temp);
return $data;
}
/**
* 获取帮助中心文章列表
*
* @access public
* @return array
*/
public function get_article_list ()
{
$data = $temp = array();
$temp['where'] = array(
'select' => 'cat_id,category',
'where' => array('parent_id' => 2),
'order_by' => 'sort_order desc,cat_id desc'
);
$data = $this->c->get_all(self::category, $temp['where']);
if( ! empty($data))
{
$temp['cat_id'] = array();
foreach($data as $v)
{
$temp['cat_id'][] = $v['cat_id'];
}
$temp['where'] = array(
'select' => 'id,title,cat_id,content',
'where_in' => array(
'field' => 'cat_id',
'value' => $temp['cat_id']
)
);
$temp['data'] = $this->c->get_all(self::article, $temp['where']);
foreach($data as $key => $val)
{
foreach($temp['data'] as $k => $v)
{
if($v['cat_id'] == $val['cat_id'])
{
$data[$key]['article'][] = $v;
}
}
}
}
unset($temp);
return $data;
}
}
复制代码
这是类的源码....
|
|