php – 致命错误:未捕获异常’mysqli_sql_exception’,消息’查询/预准备语句中没有使用索引’

前端之家收集整理的这篇文章主要介绍了php – 致命错误:未捕获异常’mysqli_sql_exception’,消息’查询/预准备语句中没有使用索引’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我运行以下代码时,我收到错误

Fatal error: Uncaught exception
mysqli_sql_exception’ with message
‘No index used in query/prepared
statement’

$MysqL = new MysqLi(DB_SERVER,DB_USER,DB_PASSWORD,DB_NAME) or die('There was a problem connecting to the database');
        if (MysqLi_connect_errno()) {
            printf("DB error: %s",MysqLi_connect_error());
            exit();
        }

    $get_emp_list = $MysqL->prepare("SELECT id,name FROM calc");
    if(!$get_emp_list){
        echo "prepare Failed\n";
        echo "error: ",$MysqL->error,"\n";
        return;
    }
    $get_emp_list->execute();
    $get_emp_list->bind_result($id,$emp_list);

这是有能力的架构 –

--
-- Table structure for table `calc`
--

CREATE TABLE IF NOT EXISTS `calc` (
  `id` int(12) NOT NULL,`yr` year(4) NOT NULL,`mnth` varchar(12) NOT NULL,`name` varchar(256) NOT NULL,`paidleave` int(12) NOT NULL,`balanceleave` int(12) NOT NULL,`unpaidleave` int(12) NOT NULL,`basesalary` int(12) NOT NULL,`deductions` int(12) NOT NULL,`tds` int(12) NOT NULL,`pf` int(12) NOT NULL,`finalsalary` int(12) NOT NULL,PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
看看这个错误报告: #35450 mysqli extension reports too many warnings

引用一个注释的几句话:

MysqLi extension throws too many
warnings.
For example,“SELECT *
FROM table” results in a warning:
“Warning: MysqLi::query(): No index
used in query/prepared statement
SELECT * FROM table …”

并引用另一个注释,这看起来很有趣:

Use MysqLi_report() to disable that.

不幸的是,Humph,that function已被弃用……

原文链接:https://www.f2er.com/php/136099.html

猜你在找的PHP相关文章