I have a query
INSERT INTO table (id) VALUES (5);
The table already has a record with such ID. So the query fails.
My mysqli class extension looks like this:
<?php
class my_mysqli extends mysqli {
function __construct($config) {
$this->DB = parent::__construct($config['HOST'], $config['USER'], $config['PASS'], $config['DB']);
}
function exe($sql) {
if ( ! $st = $this->DB->prepare($sql)) {
trigger_error($st->error); // this one isn't triggered
}
if ( ! $st->execute()) {
trigger_error($st->error); // this one is triggered
}
// ..then parse results and close
}
}
Right after $mysqli->execute()
I log $mysqli->error
and get:
*Unknown prepared statement handler (0) given to mysqld_stmt_execute*
But I would like to see the SQL error instead:
Duplicate entry '5' for key 'PRIMARY'