用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1871|回复: 9
收起左侧

CI $this 疑惑???

[复制链接]
发表于 2015-8-31 11:32:32 | 显示全部楼层 |阅读模式
ci 中 $this->c->getfaction("test","true");这里的c 是什么含义??????
发表于 2015-9-7 18:35:49 | 显示全部楼层
c 是CI的类库
发表于 2015-8-31 13:35:04 | 显示全部楼层
这个 C 应该是代码里自己写的,不是 CI 里的东西。
 楼主| 发表于 2015-8-31 14:10:53 | 显示全部楼层
本帖最后由 jions7ihj 于 2015-8-31 14:12 编辑

我找了,没找到啊,,,,,c 本来是当前类的成员数据么,,,但是类里就是没有定义过,
发表于 2015-8-31 14:16:47 | 显示全部楼层
也許你可以提供該文件的所有代碼
我們才能幫你發現出處
发表于 2015-8-31 14:44:40 | 显示全部楼层
jions7ihj 发表于 2015-8-31 14:10
我找了,没找到啊,,,,,c 本来是当前类的成员数据么,,,但是类里就是没有定义过, ...

代码打包发上来。

发表于 2015-8-31 15:24:36 | 显示全部楼层
这个$this->c肯定是你全局初始化的时候定义了一个,比如在一个公共模型里面做了这个步骤:
public $c;
public function __construct()
{
    parent::__construct();
    $this->load->model('config_model');
   $CI =& get_instance();
   $CI->c = $this->config_model;
}
 楼主| 发表于 2015-9-1 08:51:57 | 显示全部楼层
Hex 发表于 2015-8-31 14:44
代码打包发上来。
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;
    }
}
 
复制代码

这是类的源码....

发表于 2015-9-1 10:02:22 | 显示全部楼层
jions7ihj 发表于 2015-9-1 08:51
这是类的源码....

代码不全,明显没有定义 c 的地方。
把代码目录压缩后传上来。

本版积分规则