mysqli_real_connect返回无法选择指定的数据库

时间:2014-05-09 07:24:39

标签: php codeigniter mysqli

我正在使用mysqli_real_connect在我使用codeigniter的代码上启用LOAD DATA LOCAL INFILE。

我对mysqli_driver代码进行了以下更改

function db_connect()
{

    $handle = mysqli_init();

    if(!$handle) {

        die("mysqli_init failed");
    }

    else {

        mysqli_options($handle, MYSQLI_OPT_LOCAL_INFILE, true);

        if ($this->port != '')
        {
            return @mysqli_real_connect($handle,$this->hostname, $this->username, $this->password, $this->database, $this->port);
        }
        else
        {
            return @mysqli_real_connect($handle,$this->hostname, $this->username, $this->password, $this->database);
        }
    }       

}

这是原始代码

 */
function db_connect()
{
    if ($this->port != '')
    {
        return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port);
    }
    else
    {
        return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database);
    }

}

更改代码后我现在面临的问题是即使我正确地提到了数据库,我也会收到以下错误

Unable to select the specified database: dashboard

Filename: core/Loader.php

Line Number: 346

这是Loader.php代码

上的内容
public function database($params = '', $return = FALSE, $active_record = NULL)
{
    // Grab the super object
    $CI =& get_instance();

    // Do we even need to load the database class?
    if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db))
    {
        return FALSE;
    }

    require_once(BASEPATH.'database/DB.php');

    if ($return === TRUE)
    {
        return DB($params, $active_record);
    }

    // Initialize the db variable.  Needed to prevent
    // reference errors with some configurations
    $CI->db = '';

    // Load the DB class
    $CI->db =& DB($params, $active_record);
}

第346行是$CI->db =& DB($params, $active_record);

有人可以帮我解决我的代码有什么问题以及如何解决这个问题?感谢

0 个答案:

没有答案