我可以在使用 CodeIgniter 时访问 mysqli::get_warnings() 吗?


Can I access mysqli::get_warnings() when using CodeIgniter?

mysqli 连接对象上的 get_warnings() 函数返回有用的警告,例如 Warning: 1366: Incorrect integer value: '' for column 'published' 。这些警告有助于构建可靠的代码。

我可以从CodeIgniter访问那里的警告消息吗?

CI

提供了$this->db->error();,它将返回一个包含错误代码和消息的数组。我不确定此列表中是否显示警告

可以直接

执行 PHP mysqli 函数。您需要运行一个返回 CI_DB_result 的 CI 函数。从那里你可以访问成员conn_id,它可以用作PHP的mysqli扩展的许多过程方法使用的mysqli $link

$query = $this->db->get('some_table');
//$query is of type CI_DB_result
//Use it to run PHP mysqli function directly
$row_count = mysqli_affected_rows($query->conn_id);

我已经对此进行了测试,它可以工作,mysqli_field_count($query->conn_id);

我希望mysqli_get_warnings ($query->conn_id)也能工作。