简体   繁体   English

如何使用Zend_Db有效读取大量行?

[英]How to read large number of rows efficiently using Zend_Db?

Is there a simple :) and efficient way or reading very large number of rows sequentially using Zend_Db? 是否有一种简单的:)高效方式,还是使用Zend_Db顺序读取大量行?

Basically I need to process entire table, row by row. 基本上,我需要逐行处理整个表。 Table is large, primary key sequence is not guaranteed(ie not an autoincrement, but is UNSIGNED INT). 表很大,不能保证主键序列(即不是自动递增,而是UNSIGNED INT)。 What's the best way to approach this? 解决此问题的最佳方法是什么?

Environment: PHP 5.2, Zend Framework 1.10, MySQL 5.1 环境:PHP 5.2,Zend Framework 1.10,MySQL 5.1

You could always load a subset of records using the limit function. 您始终可以使用limit函数加载记录的子集。

$table = new Default_Models_Something();
$table = $table->fetchAll($table ->select(true)->limit(10, $offset));

So with that logic you find out how many records are in the table and then extract 10 records at a time incrementing your offset everytime. 因此,利用这种逻辑,您可以找出表中有多少条记录,然后一次提取10条记录,每次都会增加偏移量。

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

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