I am trying to perform a query and am getting the following error..
我正在尝试执行查询,并收到以下错误..
7Error: No index used in query/prepared statement SELECT `id`, `category_id`, `topic_id`, `post_creator`, `post_content`, `post_date` FROM forum_posts WHERE `category_id`=? AND `topic_id`=?
I originally had this line of code for it...
我最初有这行代码...
if($stmt2 = $con->prepare("SELECT * FROM forum_posts WHERE `category_id`=? AND `topic_id`=?")) {
So I tried changing it to the following to give it an index.
所以我尝试将其更改为以下内容以给它一个索引。
if($stmt2 = $con->prepare("SELECT `id`, `category_id`, `topic_id`, `post_creator`, `post_content`, `post_date` FROM forum_posts WHERE `category_id`=? AND `topic_id`=?")) {
Why would this error be occuring? I have php error reporting on.
为什么会出现这个错误?我有php错误报告。
error_reporting(E_ALL);
ini_set('display_errors', 1);
However, even when I comment it out, the error still occurs and it kills my code. Anyone know why this error is coming up and how I can fix it?
但是,即使我将其注释掉,错误仍然会发生并且会导致我的代码被杀死。任何人都知道为什么会出现这个错误以及如何修复它?
1 个解决方案
#1
1
According to the answer provided here:
根据这里提供的答案:
mysqli_report(MYSQLI_REPORT_ALL ^ MYSQLI_REPORT_INDEX);
mysqli_report(MYSQLI_REPORT_ALL ^ MYSQLI_REPORT_INDEX);
Turns off "Report if no index or bad index was used in a query" yet keeps other reporting on.
关闭“如果查询中没有使用索引或错误索引,则报告”但仍保留其他报告。
By using 'E_ALL', you are enabling the reporting of this error/warning.
通过使用“E_ALL”,您可以启用此错误/警告的报告。
#1
1
According to the answer provided here:
根据这里提供的答案:
mysqli_report(MYSQLI_REPORT_ALL ^ MYSQLI_REPORT_INDEX);
mysqli_report(MYSQLI_REPORT_ALL ^ MYSQLI_REPORT_INDEX);
Turns off "Report if no index or bad index was used in a query" yet keeps other reporting on.
关闭“如果查询中没有使用索引或错误索引,则报告”但仍保留其他报告。
By using 'E_ALL', you are enabling the reporting of this error/warning.
通过使用“E_ALL”,您可以启用此错误/警告的报告。