什么" [function.mysqli-close]:无法获取mysqli"?

时间:2015-03-18 09:36:43

标签: php database mysqli

我有一个数据库类。这是我的数据库类:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* 
*/
class W3_Db
{
    private $link;
    private $insert_id = 0;

    public function __construct()
    {
        $config = get_config();
        $this->link = mysqli_connect($config['db']["hostname"],$config['db']["username"],$config['db']["password"],$config['db']["database"]);

        if($this->link->connect_errno)
           trigger_error(mysqli_error($this->link));
        $this->link->set_charset($config["db"]["char_set"]);

        $this->insert_id = 0;

        /*
         *  load security class and create a object from it
         */

        $classname = load_class("security");
        $GLOBALS['security'] = new $classname;
        $GLOBALS['security']->setdb($this);
    }

    public function get_insert_id()
    {
        return $this->insert_id;
    }


    public function __destruct()
    {
        if ($this->link->connect_errno) {
            trigger_error("Connect failed: %s\n", $this->link->connect_error);
            exit();
        }
        mysqli_close($this->link);
    }

    public function query($query)
    {
        if ($this->link->connect_errno) {
            trigger_error("Connect failed: %s\n", $this->link->connect_error);
            exit();
        }
        $rsl = $this->link->query($query) or trigger_error(mysqli_error($this->link)."<br> query is: ".$query);

        $this->insert_id = mysqli_insert_id($this->link);
        return $rsl;
    }

    public function get_connection()
    {
        return $this->link;
    }
}?>

但是当我加载它时,我在mysqli_close($ this-&gt; link)行看到了这个错误;

  

&#34;自定义错误:[2] mysqli_close()[function.mysqli-close]:无法解决   获取mysqli&#34;

0 个答案:

没有答案