On 5/31/07, StinkyTofu <[EMAIL PROTECTED]> wrote:
>
>
> I am calling $this->Member->findAll(null, 'Member.id') on a database
> of 8000 records and am receiving the following error:
>
> Allowed memory size of 16777216 bytes exhausted (tried to allocate 782
> bytes) in /home/web88/html/cake/libs/model/datasources/dbo_source.php
> on line 312
>
> I assume this error is happening because the server is loading too
> many records into the array. The issue here is that I need to take
> all the member records and insert them into a .csv file, so I cannot
> use the SQL 'LIMIT' function as that will mean that only a portion of
> the records will be imported into the csv.
The replies you've received are all valid (specially the one from AD7Six
about using a limit and looping until there are no more records) but the way
I solved it, which is probably not the nicest way, is to increase the PHP
memory_limit for the action that has to do the CSV export like so:
In your controller:
function admin_export()
{
ini_set( "memory_limit","32M" );
set_time_limit(120);
$records = $this->Member->findAll(null, 'Member.id');
// etc...
}
Since the CSV exporting feature wouldn't be used that often (in my case),
it's not that bad a solution. Keep in mind I have about 1500 records which
don't tend to increase all that often, and you have 8000, so AD7six's
solution is probably a better fit. See how you go.
Regards,
Gonzalo.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---