Frameworks: Light on the SQL, Please

Cake, the rapid development framework for PHP, makes life 10,000% easier for developers everywhere by providing us with an ActiveRecord pattern for performing the most used database interaction methods: Create, Read, Update, and Delete (CRUD). It’s modeled closely off of Ruby on Rails’s ActiveRecord, for those who are more familiar with that framework.

As a Rails developer I’ve seen the limits of ActiveRecord, and the performance issues it gets when dealing with large, complex database types. But to be honest, I’ve never been a big fan of the Ruby language, and part of me assumed that was just Ruby being slow. I was convinced that with a good framework, ActiveRecord could be used (efficiently) in complex database environments.

Yesterday that blind faith was taken to the test as I attempted to optimize a CSV generator. The problem was simple: the query which collected a table’s information, was producing an array which was way too large – the database table had close to 60,000 records and at 9.something MB, was throwing PHP memory allocation errors left and right.

Right now it stands at Heavyweight SQL: 1 / CakePHP: 0. However, I am determined to find a way to make complex databases work well with Cake – I still have a lot to learn about this framework, and I have belief in it.

1 Response to “Frameworks: Light on the SQL, Please”


  1. 1 nate

    Trying to fit everything into ActiveRecord is missing half the point. ActiveRecord will *never* be able satisfy all cases, and that’s okay. The solution there is to wrap the custom SQL in a model method, and add parameters as necessary.

Leave a Reply