Active Record Maximum Number Of Rows

Hello,

I am going to use the findBy-Method to select about 10000 rows.

My question is if this is a good idea or this can cause problems…

Would it be better if I use DAO or what should I do.

I want to create a Job (server-side automated application) that selects all necessary datarows and uses something like a foreach-loop to calculate data from this rows.

How should I solve this? I am using PostgreSQL AND Oracle on the server…

If you want calculate date from database rows. And it will about 10 000 rows, better if you will calculate it in database query. What you need callculate??? Maybe I can help you.

I don’t have only to calculate data, but I have to create documents (PDFs, docx) from the data in the database, too…

For this I have to make the loop in the programming language…

The main problem with AR is that it takes much memory… so it’s not a good candidate for large volumes of data…

By using DAO or the query builder you are getting all the data in a simple PHP array… depending on your data records this too can get to a memory problem…

So the best solution for very large volume of data is to use a database reader… in Yii we have CDbReader - http://www.yiiframework.com/doc/api/1.1/CDbDataReader

To get a CDbDataReader you need to use the query() method http://www.yiiframework.com/doc/api/1.1/CDbCommand#query-detail

wow, thank you. Could you tell me how this datastream works? Does it make automated limitations while it’s reading the data from the database? I hope it doesn’t make a select wildchar from ;)

Can I use this object with the cdbcriteria or something like this?

I need something like the reader but with a simple database abstraction. Would like to use this with Postres and Oracle without the need to change anything. :)

No limitations needed, it gets only row by row data as you request it… note this is "forward only", it means you cannot get the previous record only the next one…

If you are interested how this works in the background… Yii just uses the PHP PDO statements for this, so check that documentations for more info.

For more Yii details check this documentation - http://www.yiiframework.com/doc/guide/1.1/en/database.dao