Welcome Guest, Not a member yet? Register   Sign In
CRUD Model for Codeigniter 2.0
#6

[eluser]JonoB[/eluser]
Maybe its just personal preference, but having all those CRUD functions automatically loaded and available for use with all my other models makes CRUD coding much faster and simpler for me. And more extensible and intuitive. Whether you are extending CI_Model or MY_Model is pretty much irrelevant if MY_Model only contains 1000 lines or so.

Oh, and you dont have to call the 'use_table' method every time...you can have MY_Model automatically work this out from the class that being called - just inflect it from the class name. Something like:

Code:
private function _fetch_table()
{
  if ($this->_table == NULL)
  {
    $class = preg_replace('/(_m|_model)?$/', '', get_class($this));
    $this->_table = strtolower($class);
  }
}

Nothing 'wrong' per se with your approach.


Messages In This Thread
CRUD Model for Codeigniter 2.0 - by El Forum - 05-24-2011, 11:21 PM
CRUD Model for Codeigniter 2.0 - by El Forum - 05-25-2011, 04:00 AM
CRUD Model for Codeigniter 2.0 - by El Forum - 05-25-2011, 10:55 AM
CRUD Model for Codeigniter 2.0 - by El Forum - 05-25-2011, 03:21 PM
CRUD Model for Codeigniter 2.0 - by El Forum - 05-25-2011, 04:48 PM
CRUD Model for Codeigniter 2.0 - by El Forum - 05-26-2011, 03:31 AM
CRUD Model for Codeigniter 2.0 - by El Forum - 05-29-2011, 10:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB