When I execute sql queries on my php applciation using MySQLi, errors are always empty or null so disabling me from logging or printing them which is rather frustrating... I have not experienced any issues inserting, updating or deleting data with the snippet below when the query is not expected to raise an error.
I am using PHP 5.3.9 on the community edition of Zend Server 5.6.0 and mysqli mysqlnd 5.0.8-dev - 20102224 - $Revision: 318113 $
This is the code that executes my queries :
...
$this->last= $this->mysqli->query($sql);
if (!$this->last)
{
print_r($this->mysqli);
var_dump($this->mysqli->error);
var_dump($this->mysqli->errno);
var_dump($this->mysqli);
$msg = 'Query failed [ ' . $this->mysqli->error . ' ]';
$this->mysqli->rollback();
throw new Exception($msg, ...);
}
...
For testing purposes I insterted a city named 'bob' in my database and tried to insert another city with the same name and this is what was printed :
mysqli Object
(
...
[errno] => 1062
[error] => Duplicate entry 'bob' for key 'unq_city'
...
)
string(0) ""
int(0)
object(mysqli)#6 (18) {
...
["errno"]=>
int(0)
["error"]=>
string(0) ""
...
}
Here using var_dump or accessing the errno or error of my mysqli object is, as I previously stated, null. HOWEVER print_r shows the expected error! What I am doing wrong here? I never used mysqli before and am migrating from oci8 so I hope it's only some stupid mistake.
I tested my app on an older server, PHP 5.3.8, ZSCE 5.5.0 and mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $ with identical configuration from what I can tell. All dumps and prints showed the entire mysqli data without any empty field!