2008年11月24日星期一

[fw-db] Re: Re: Re[fw-db] s: Parsing through large result sets

Hi and thanks for the reply.

However that wouldn't make it work the way I want and if I want to iterate through a very large set of data, then that should be possible without using limits.

It can be done without any problems whatsoever if I use the "builtin" mysql*-functions. It takes a second or so to execute the $res = mysql_query($sql); command and then I can easily and without any big memory consumption do a while ($row = mysql_fetch_assoc($res)) { ... } on that result set.

I am looking for the very same thing as that, however I would very much like to keep using the Zend Framework.'

Best regards,
Jan
keith Pope-4 wrote:
You need to limit your query if you have a large dataset. 2008/11/24 janpolsen : > Oi > > Now I have tested fetching large amount of data in various scenarioes, but I > simply can't figure out how to get it work. I understand what you write > below, but to me it looks like that PHP bails out with the "memory > exhausted" error already when I do the ->query(). > > I have tried 3 verious methods of fetching data: > > $sql = "SELECT * FROM "; > > $stmt = new Zend_Db_Statement_Pdo($db, $sql); > $stmt->execute(); > while ($row = $stmt->fetch()) { > echo $row['SecurityID'].PHP_EOL; > } > > $res = $db->query($sql); > while ($row = $res->fetch()) { > echo $row['SecurityID'].PHP_EOL; > } > > $res = $db->fetchAll($sql); > foreach ($res AS $row) { > echo $row['SecurityID'].PHP_EOL; > } > > All three of them fails with PHP Fatal error: Allowed memory size of > 536870912 bytes exhausted (tried to allocate 40 bytes) in > L:\Internet\php\includes\ZendFramework-1.7.0\library\Zend\Db\Statement\Pdo.php > on line 234 > > Notice that I have my memory_limit in PHP set to 512MB! > > To me it seems like all of the three fetch-methods tries to fetch the whole > dataset right away, instead of one row at a time. > > Am I using the methods wrong or? > > Best regards, > Jan


View this message in context: Re: Re: Re[fw-db] s: Parsing through large result sets
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: