- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我们的 PHP 代码中的许多地方,(如果重要的话使用 postgres)我们有这样的东西:
$q = "SELECT DISTINCT a.id FROM alarms.current a, entities e, installations i ";
$q .= "WHERE i.\"entityId\"=e.id AND a.installationid=i.id AND ";
$q .= "e.id=".$entityId;
$stmt = $db->query($q);
$stmt->bindColumn("id", $alarmId);
if ($stmt->fetch(PDO::FETCH_ASSOC))
....etc
现在根据我对文档的阅读,如果您希望从它们的绑定(bind)列更新您的变量,您应该使用 PDO::FETCH_BOUND。但我们没有,据我所知,没有人提示性能。
谁能解释为什么这个明显错误的代码实际上有效?
最佳答案
虽然 bindColumn
的 PHP 文档中的示例使用 PDO::FETCH_BOUND
,这确实表明这种获取样式是使用 bindColumn< 所必需的
,它没有明确说明这是一项要求。它只是说
PDOStatement::bindColumn() arranges to have a particular variable bound to a given column in the result-set from a query. Each call to PDOStatement::fetch() or PDOStatement::fetchAll() will update all the variables that are bound to columns.
经过一些测试后,我确定无论使用何种提取样式,都会发生这种情况。我认为您的代码中的 fetch
调用实际上并未提取到变量中,这实际上只是意味着创建了一个关联数组并将其分配给任何内容,而提取的副作用填充了 $alarmId
变量。
关于php - PDO bindColumn 和 PDO::FETCH_BOUND——强制的还是可选的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34438490/
我正在尝试用 Swift 编写这段 JavaScript 代码:k_combinations 到目前为止,我在 Swift 中有这个: import Foundation import Cocoa e
我是一名优秀的程序员,十分优秀!