October 1st, 2007
After a month of use, I’m still a big fan of Code Igniter; it’s a lightweight PHP framework that hasn’t got in my way, which is a big factor regarding how long things last. I particular like its flexibility regarding handling URLs, as it doesn’t force you to use its default segment-based approach, providing direct regex URL / Object mapping, or if you so wish, an option to revert back to plain HTTP GET. Other frameworks can do similar things, but they don’t all work on PHP 4, and don’t all have the same quality of documentation.
Nevertheless there was something I found confusing to begin with: the use of the Active Record pattern in the model. Not knowing about Active Record, I was left asking: where are my model constructor arguments? To demonstrate, you can’t do something like this:
$this->load->model("foo", array("id" => 1));
To do so you have to implement your code in terms of a library. For models, think of your class as a representation of a table, which provides standard CRUD functionality, with member variables instead of constructor arguments:
$this->load->model("table_name"); $this->table_name->id = 1; $this->table_name->text = "Example"; $this->table_name->update();