为什么会这样?我怎么解决呢?

时间:2016-05-02 15:01:17

标签: codeigniter ionic-framework

严重程度:8192

消息:mysql_connect():不推荐使用mysql扩展,将来会删除它:使用mysqli或PDO代替

文件名:mysql / mysql_driver.php

行号:136

回溯:

文件:C:\ wamp \ www \ ci \ application \ controllers \ c_testing.php 行:27 功能:__construct

文件:C:\ wamp \ www \ ci \ index.php 行:315 功能:require_once

  在databease.php的codeigniter文件中

我用这个

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost:81',
    'username' => 'root',
    'password' => '1234',
    'database' => 'testing',
    '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
);
  

然后在我的testing.php文件中

Class Testingdata extends CI_Model{
    function __construct(){
        parent::__construct();
        $this->load->database();
        $this->db->reconnect();
    }

    // data obtained from database 
    function get_data(){
        $this->db->select('*');
        $this->db->from('lecturer_profile');



        $query = $this->db->get();
        return $query->result();
    } 
}

?>`enter code here`

1 个答案:

答案 0 :(得分:0)

您需要更改数据库配置。转到项目/application/config/database.php中的以下路径,找到dbdriver设置并确保其为mysqli