简体   繁体   English

当已知数据集时,是否可以将PHP PDO与SplFixedArray一起使用?

[英]Is there a way to use PHP PDO with SplFixedArray when dataset is known?

I would like to use http://uk3.php.net/manual/en/pdostatement.fetchall.php together with a query that returns a dataset of defined length. 我想将http://uk3.php.net/manual/en/pdostatement.fetchall.php与返回定义长度的数据集的查询一起使用。

Does PDO support fetching into http://php.net/manual/en/class.splfixedarray.php object or do I need to iterate the result set? PDO是否支持提取到http://php.net/manual/zh/class.splfixedarray.php对象,还是需要迭代结果集?

If standard array consumes too much memory, then pass a PDO statement instead, and iterate over it, using PDOStatement::fetch() . 如果标准数组消耗太多内存,则改为传递PDO语句,然后使用PDOStatement::fetch()在其上进行迭代。 It will consume no memory at all (especially if you set PDO::MYSQL_ATTR_USE_BUFFERED_QUERY to false ) 它将完全不占用内存(特别是如果您将PDO::MYSQL_ATTR_USE_BUFFERED_QUERY设置为false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM