扩展mysqli - 重载执行()

时间:2014-03-27 05:11:28

标签: php mysqli

我已经扩展了MySQLi类:

class my_mysqli extends MySQLi
{
public $queries = 0;

function __construct($host = '', $user = '', $pass = '', $db = '')
{
    if (is_object($host) or $host == '')
    {
        parent::__construct(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);

        if ($this->connect_error)
        {
            my_error('Cannot connect to MySQL server: ' . $this->connect_error);
        }
    }

    else
    {
        parent::__construct($host, $user, $pass, $db);
    }
}

public function prepare($query)
{
    $p = parent::prepare($query);

    $this->check_error();

    return $p;
}

public function execute()
{
    $this->queries++;

    parent::execute();
}

public function query($query)
{
    $p = parent::query ($query);

    $this->check_error();

    $this->queries++;

    return $p;
}

public function check_error()
{
    if ($this->error)
    {
        my_error($this->error, true);
    }
}

}

问题是,execute()没有发生任何事情。我该怎么做才能重载这个方法?现在,它被忽略了。根据php.net网站,execute方法不需要参数。有点亏。

0 个答案:

没有答案