[eluser]darkhouse[/eluser]
First, great work. This will definitely save me some time.
What's the best practice when you need to use order_by? Do you just create a model function like you would normally, and then use $this->get_many_by() or $this->get_all()? Seems like it should be part of the base model, but I'm not really sure what the best way to handle it would be considering you're using func_get_args to manage the where data.
Edit: I just realized there's an order_by method, so I'm guessing the best practice is to do:
Code:
$this->some_model->order_by('title');
$stuff = $this->some_model->get_all();
Also, maybe you have your reasons for doing it the way you did it, but I think you could change the insert_many function from this:
Code:
public function insert_many($data) {
$ids = array();
foreach ($data as $row) {
$data = $this->_run_before_create($row);
$this->db->insert($this->table, $row);
$this->_run_after_create($row, $this->db->insert_id());
$ids[] = $this->db->insert_id();
}
return $ids;
}
to this:
Code:
public function insert_many($data) {
$ids = array();
foreach ($data as $row) {
$ids[] = $this->insert($row);
}
return $ids;
}
Just gets rid of some redundancy. I'm a fan of DRY, I noticed you did that for get_many_by using get_all, so I figured why not this function.