- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将我的 php/mySQL 代码转换为使用准备好的语句。我可以看到准备 SQL 或 DML 以及绑定(bind)参数的值(value)(安全性等)。但我的查询按名称指定选择列表中的字段,并且我使用关联数组来访问它们。
或者,是在像这样的情况下提供帮助,我必须对结果数组中的索引做出假设吗?
$listquery = "SELECT {$tables["result"]}.time, " .
" HOUR({$tables["result"]}.time), " . // [1]
" MINUTE({$tables["result"]}.time), " . // [2]
" SECOND({$tables["result"]}.time), " . // [3]
" {$tables["rider"]}.id, {$tables["rider"]}.gender, " .
" {$tables["rider"]}.first, {$tables["rider"]}.last, " .
" {$tables["result"]}.dnf, " .
" {$tables["race"]}.courseid " .
" FROM {$tables["race"]}, {$tables["result"]}, {$tables["rider"]} " .
" WHERE {$tables["race"]}.raceid = {$tables["result"]}.raceid " .
" AND {$tables["result"]}.riderid = {$tables["rider"]}.id" .
" AND {$tables["race"]}.raceid = ? " .
" ORDER BY {$tables["result"]}.dnf, {$tables["result"]}.time ASC ";
最佳答案
如果您使用MYSQLND
驱动程序,则可以使用mysqli_fetch_assoc
或mysqli_stmt_bind_param
来获取准备好的查询的结果。这两种方法都没有特别的好处。
如果您没有 MYSQLND
驱动程序,获取 SELECT
查询结果的唯一方法是使用 mysqli_stmt_bind_param
。
您使用关联数组来指定表名称并不真正相关。您仍在 AND {$tables["race"]}.raceid = ?
中使用占位符,因此您需要准备查询。
关于php - mysqli_stmt_bind_result 有什么优点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35780471/
我正在将我的 php/mySQL 代码转换为使用准备好的语句。我可以看到准备 SQL 或 DML 以及绑定(bind)参数的值(value)(安全性等)。但我的查询按名称指定选择列表中的字段,并且我使
好吧,这让我很烦,我似乎无法在 PHP 文档中找到任何内容,也无法在 Google resultosphere 的任何地方找到任何内容,所以也许有人可以在这里提供帮助。 我正在使用准备好的语句、绑定(
我正在尝试使用 mysqli_stmt_bind_result() 但我认为我没有正确使用它。下面的代码获取用户名和密码并在数据库中运行查询,如果匹配则返回成功。 但是,当我打印出该行时,它是空的。我
将 PHP 脚本从 PHP 5.2 迁移到 PHP 5.3 时,我遇到了以下问题:该脚本的一般用途是数据挖掘。我有一个向 MySQL 服务器添加数据的程序。因为它确实是重复的,所以我(不久前)重写了它
所以我尝试创建一个 UNION 查询,这样我就可以从两个表(同一个数据库)中获取数据,稍后我尝试使用 mysqli_bind_result( ),但出现错误: mysqli_stmt_bind_res
这个问题已经有答案了: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in p
我是一名优秀的程序员,十分优秀!