0

我有一个扩展 MySQLi 类的自定义数据库类。

parent它使用该方法连接到数据库__construct

以下是查询的部分,如果查询不成功,如何从服务器返回错误?

$query =  parent::query($querystr, $resultmode);
    if (!$query) {
        $error = str_replace(
            'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use',
            'Syntax Error',
            mysqli_error(self::getInstance()));
        \core\debug::sqlerrorlog($error);
    } else {
        \core\debug::sqlSuccess();
    }
4

1 回答 1

0

根据文档,您只需要这样做$this->error

据我了解,您现在的问题是您没有将正确的 mysqli 实例传递给mysql_error- 也许self::getInstance()没有做它应该做的事情,但我无法从我所看到的情况中判断出来。

于 2012-11-24T00:08:08.987 回答