i’m using activerecords and cdbcriteria to search in joined tables. The result is displayed by using pagers so that there are only a few records to get from database.
Now i need to get all records fitting the specified criteria. But i get a memory error because producing 5000 activerecords with related objects is too much for my server.
How can I extend the activerecord class and activefinder class to get arrays as result of the query instead of activerecords.
Or perhaps there is a way to get the sql statement created by the findAll function of activerecord - without executing it?
I would be glad if you could give me some help. (Using DAO will make the creation of my search condition much more complex)
Best regards - datatraders
You read about the new query builder right? I do not think will be very hard to create any SQL statement.
Then, just use the queryAll
Nevertheless, the return of 5000 rows I think is a hell of a query… do you really require to return so many records?
The records should be exported - all records a user could filter and display should also be available as download.
I use the activerecord implementation because of the validation, scopes and behaviors features. Using the querybuilder too would mean to take care about 2 different data access methods - in a case of database change.
Perhaps there is a better alternative?
IMHO I would not use AR for such amount of records. Even though the creation of a DAO could be more complex, I think for ‘exportation purposes’ I would use DAO and for paging visualization use AR.
Are you saying that if a user makes a search and there is 5000 records returned query, you display them all? Dont you use pagination?
But: that means to take care about 2 different data access methods - in a case of database change.
I’m using paging visualization with AR. So there is no problem for users to view such amount of records because it become paged. But on export the same query result I cannot use paging, so the activerecord findAll() function will result in a memory error.
I like to use the same mechanism for the search query and the export query.