PDO MySQL fetchAll() 在结果中使用双倍的必要内存?
当我将 ->fetchAll()
与 PDO 一起使用时,当我执行 print_r()
时,结果数组看起来像这样:
Array
(
[0] => Array
(
[week] => 2006-03-05
[0] => 2006-03-05
[ath] => 112.89166667
[1] => 112.89166667
)
[1] => Array
(
[week] => 2006-03-12
[0] => 2006-03-12
[ath] => 260.04527778
[1] => 260.04527778
)
[2] => Array
(
[week] => 2006-03-19
[0] => 2006-03-19
[ath] => 219.23472222
[1] => 219.23472222
)
等等,
结果值是否存储记忆中两次?一个位于数字数组索引下,例如 0
和 1
,另一个位于其命名索引下,例如 week
或 ath?
我主要只是好奇。我不认为这会对我的计划产生重大影响。谢谢。
When I use ->fetchAll()
with PDO, the resulting array looks like this when I do a print_r()
:
Array
(
[0] => Array
(
[week] => 2006-03-05
[0] => 2006-03-05
[ath] => 112.89166667
[1] => 112.89166667
)
[1] => Array
(
[week] => 2006-03-12
[0] => 2006-03-12
[ath] => 260.04527778
[1] => 260.04527778
)
[2] => Array
(
[week] => 2006-03-19
[0] => 2006-03-19
[ath] => 219.23472222
[1] => 219.23472222
)
etc., etc.
Are the resulting values stored twice in memory? One under a numerical array index like 0
and 1
, and the other under its named index, such as week
or ath
?
I am mainly just curious. I don't expect this to really impact my program significantly. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。请参阅手册:
使用可选的
$fetch_style
参数更改 fetchAll() 的行为方式。Yes. See the manual:
Use the optional
$fetch_style
parameter to change the way fetchAll() behaves.