Hi, In my cake application (1.2, apache, mysql), I need to export a large amount of data (tens of thousands of records or more) in XML format. The query itself is heavy but nothing the application/database shouldn't handle reasonably (it takes ~1-2 seconds to complete the query itself).
I first tried the naive way of just calling find() and passing the result to an XML view. This, of course, chokes the application pretty quickly and PHP runs out of memory. Next I tried "paging" the query internally within one call in my controller, rending each chuck and flushing the output buffer manually. This worked better but it is taking way too long since I now have dozens of queries instead of one, each taking over a second to complete. Now I know there must be a way to achieve this since running the same query in phpmyadmin and exporting the result as XML works very well. I guess that in this case I need to somehow bypass some of cake mechanisms, iterate over the result set myself and steam the data to the client. But I still want to use some of cake's strengths when possible so I figured I need to do something like this. * use cake for the request: routes, controller/action, parse input parameters * use cake models to generate the find query * obtain the SQL query from cake * get the active mysql database connection from cake * execute the query on the raw connection * iterate over the result set, generate the XML elements, sending chucks of data to the client and flushing as needed. (when the above works I may save the XML to intermediate file for caching and redirect to that file, using cake's cache to control expiration). Does the above make sense or is there any better way to achieve my goal? How do I get the raw SQL query for my models without executing it? How do I get the database connection? Any help is appreciated. Thanks! - barduck Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en