更新时间:2023-12-04 13:13:46
考虑结果集的堆栈,每个fetch()调用都会弹出结果行.您在while循环之外调用了一次fetch,然后显然将$ result丢弃了.这意味着一行结果数据不见了.至于将它们放入对象/数组中,则取决于您.可能很简单:
Consider the result set a stack, and each fetch() call pops off a result row. You've called fetch once OUTSIDE of the while loop, and then apparently thrown away $result. That means one row of result data is gone. As for putting them into an object/array, that's up to you. could be as simple as:
$addresses[] = $row['StreetAddress1']
在循环内部.
两个
while($row = $sth->fetch()) {
...
}
-- or --
$rows = $sth->fetchAll();
foreach($rows as $row) {
...
}