我有一个查询
INSERT INTO table (id) VALUES (5);
该表已有具有该 ID 的记录。所以查询失败。
我的 mysqli 类扩展如下所示:
<?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
    }
}
在$mysqli->execute()我登录$mysqli->error并得到:
*给mysqld_stmt_execute的未知准备语句处理程序(0)*
但我想改为查看 SQL 错误:
键“PRIMARY”的重复条目“5”