If you use findAll
, then all records will be returned without any limit applied. However, CActiveDataProvider
automatically paginates results if you don't tell it otherwise. As mentioned in the comments, you are likely running out of memory when using findAll
. Using a limit or pagination (which automatically applies a limit) lowers the returned number of rows to what your application can handle.
I recommend using CDataProviderIterator to fetch large numbers of active records. Try the following sample code.
$criteria = new CDbCriteria;
$criteria->compare('country','US');
$Profiles = CDataProviderIterator(
new CActiveDataProvider(
'Profile',
array('criteria'=>$criteria)
),
10000
);
foreach ($Profiles as $Profile) {
//do whatever
}
Using the iterator, Yii will automatically fetch just 10000 records (a number you say worked without running out of memory) at a time, and then remove them from memory before grabbing the next page. Conveniently all the records can be accessed with a foreach
loop without any further work from you.
Change the 10000 value as necessary to achieve desired results. Also, make sure you are monitoring your error logs to identify out of memory and other errors.