I have the following set-up:
I want to select everything from the table, which should be no problem at all:
$table = new Application_Model_DbTable_Foo();
$everything = $table->fetchAll();
Doing this I run into a "memory exhausted" problem.
I wrote a script using PDO_MYSQL without Zend Framework and the memory usage was fine and it worked all right.
So I must be missing something here. Any hint highly appreciated. :-)
22k rows alone can a significant amount of data, depending on what your script is doing. If increasing the memory limit isn't an option, you might want to try this. Grab 'chunks' of rows. You can do this with a LIMIT. Set your page size to something that fits in memory and then process that. Keep increasing your OFFSET until you've processed all your data.
Thanx, everybody, for having a look at my problem. :-)
For further reference, if someone else has this problem, I ended up like this:
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$result = $db->query("SELECT * from footable");
foreach ($result as $row) {
//print $row["field"];
}
unset($result);
... still considering to switch to the "get it in chunks using LIMIT x,y"-suggestion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With