- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
mongo 类的 PHP 文档说 using a cursor而不是 iterator_to_array
更好。
为什么?我将从中获得什么好处/灵 active ?
最佳答案
使用 iterator_to_array()
使您的驱动程序一次将所有结果加载到内存中,并且您很容易耗尽内存。使用延迟加载的游标不会出现这种情况!
直接来自链接docs :
<?php
$cursor = $collection->find();
var_dump(iterator_to_array($cursor));
?>...
Suppose that, in the example above,
$collection
was a 50GB collection. We certainly wouldn't want to load that into memory all at once, which is what a cursor is for: allowing the client to access the collection in dribs and drabs.
关于php - MongoDB - 为什么我应该使用游标而不是 iterator_to_array(在 PHP 中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5060956/
DatePeriod是一个用于处理重复日期的 PHP 类。它的方法数量非常有限。所以当我想用重复日期做基本的数组函数时,我必须将它复制到一个数组中 iterator_to_array .奇怪的是,复制
在下面的 PHP 脚本中,iterator_to_array 效率极低(我使用了分析器)。下面的代码有更好的选择吗? $new = []; $rows=(new Mongo())->table1->f
FROM PHP DOC iterator_to_array — Copy the iterator into an array array iterator_to_array ( Traversab
在 PHP 中使用迭代器时,您可以使用 iterator_to_array 函数来提取迭代结果的数组。例如,假设您有以下 ArrayObject: $array_object = new ArrayO
我很难理解 PHP 的 iterator_to_array 函数。 我尝试阅读手册,但没有帮助。 这是什么?我该如何使用它?什么是合适的用例? 最佳答案 简而言之,iterator_to_array(
在 MongoCursor 实例上使用 iterator_to_array() 可以在 PHP 5.3 中抛出异常吗?换句话说,我是否需要在 try-catch 语句中包装对 MongoCursor
mongo 类的 PHP 文档说 using a cursor而不是 iterator_to_array 更好。 为什么?我将从中获得什么好处/灵 active ? 最佳答案 使用 iterator_
我是一名优秀的程序员,十分优秀!