Reputation: 89
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. 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?
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; also not revealed when inspected during debugging (PHPStorm). When executing the query via the command line, the (expected) error messaging is generated.
Upvotes: 1
Views: 1628