简体   繁体   English

mysqli查询返回false,但没有错误消息

[英]mysqli query returns false but no error message

I have a very straightforward SELECT query within the context of a PHP class which is returning false (failed) but I am unable to retrieve the associated error information. 我在PHP类的上下文中有一个非常简单的SELECT查询,该查询返回false(失败),但是我无法检索相关的错误信息。 The odd thing is that the call worked fine until I had to reorganize the mysql database - without revising the PHP code obviously it fails - the result is false - but where is the error message? 奇怪的是,在我不得不重新组织mysql数据库之前,该调用工作正常-在不修改PHP代码的情况下,它显然失败了-结果为false-但是错误消息在哪里?

Code is as follows: 代码如下:

<?php
class Database {
    private $_connection;
    private $_result;
    private $_lastQuery;
    private $_error;

    public function __construct($dbase) {
        $this->_connection = new mysqli(DB_SERVER, DB_USER, DB_PASS, $dbase);
        if (mysqli_connect_error()) {
            trigger_error("failed to connect to MySQL: " . mysqli_connect_error(), E_USER_ERROR);
        }
        mysqli_set_charset($this->_connection, 'utf8');
    }

    public function query($query) {
        $this->_lastQuery = $query;
        $this->_result = mysqli_query($this->_connection, $query);
        $this->_error = $this->_connection->error;
        return $this->_result;
    }
}

No error string appears in $this->_error; 没有错误字符串出现在$ this-> _ error;中。 also not revealed when inspected during debugging (PHPStorm). 在调试期间检查(PHPStorm)时也不会显示。 When executing the query via the command line, the (expected) error messaging is generated. 通过命令行执行查询时,将生成(预期的)错误消息。

看来问题出在xdebug。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM