codeigniter-base-model icon indicating copy to clipboard operation
codeigniter-base-model copied to clipboard

Created functions to make possible to create static methods on models

Open etcho opened this issue 10 years ago • 0 comments

Created functions to make possible to create static methods on models, using a static variable that is an instance of the current class and can be used to access the codeigniter methods based on objects. Would be like:

static function find($id){ self::getInstance()->db->where("id", $id); $result = self::getInstance()->db->get("user")->result(); return count($result) == 1 ? $result[0] : null; }

And can be called by $user = User::find(10);

etcho avatar Sep 17 '14 12:09 etcho