jions7ihj 发表于 2015-8-31 11:32:32

CI $this 疑惑???

ci 中 $this->c->getfaction("test","true");这里的c 是什么含义??????

XK_XK 发表于 2015-9-7 18:35:49

c 是CI的类库

Hex 发表于 2015-8-31 13:35:04

这个 C 应该是代码里自己写的,不是 CI 里的东西。

jions7ihj 发表于 2015-8-31 14:10:53

本帖最后由 jions7ihj 于 2015-8-31 14:12 编辑

我找了,没找到啊,,,,,c 本来是当前类的成员数据么,,,但是类里就是没有定义过,

Closer 发表于 2015-8-31 14:16:47

也許你可以提供該文件的所有代碼
我們才能幫你發現出處

Hex 发表于 2015-8-31 14:44:40

jions7ihj 发表于 2015-8-31 14:10
我找了,没找到啊,,,,,c 本来是当前类的成员数据么,,,但是类里就是没有定义过, ...

代码打包发上来。

jions7ihj 发表于 2015-8-31 15:08:36

晚上吧....

gogogo1027 发表于 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;
}

jions7ihj 发表于 2015-9-1 08:51:57

Hex 发表于 2015-8-31 14:44
代码打包发上来。

<?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;
    }
}

这是类的源码....

Hex 发表于 2015-9-1 10:02:22

jions7ihj 发表于 2015-9-1 08:51
这是类的源码....

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

页: [1]
查看完整版本: CI $this 疑惑???