以下是遇到的问题,如下图显示。不知道哪里出错了,有知道解决方法的大神求告知。
1、报错信息:
An uncaught Exception was encounteredType: Error Message: Cannot access protected property Blob:db Filename: /usr/local/code/ci/web/system/core/Loader.php Line Number: 396 Backtrace: File: /usr/local/code/ci/web/index.php
Line: 311
Function: require_once 2、我的db配置 $active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '111111',
'database' => 'demo',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
3、我的调用方式
class Blob_model extends CI_Model{
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function get_list(){
$res=$this->db->get('user');
var_dump($res);
}
}
4、报错行数对应的代码部分
public function database($params = '', $return = FALSE, $query_builder = NULL)
{
// Grab the super object
$CI =& get_instance();
// Do we even need to load the database class?
if ($return === FALSE && $query_builder === NULL && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id))
{
return FALSE;
}
require_once(BASEPATH.'database/DB.php');
if ($return === TRUE)
{
return DB($params, $query_builder);
}
// Initialize the db variable. Needed to prevent
// reference errors with some configurations
$CI->db = ''; 注:这就是396行
// Load the DB class
$CI->db =& DB($params, $query_builder);
return $this;
}
|