php - What is the right way to group my methods inside a single model? -
i'm sorry title, maybe couldn't describe well. here's want:
now if create model m.php , put inside models folder following code:
class m extends ci_model { public function username() { print "john doe"; } public function password() { print "abc123"; } }
now, can following in controller :
$this->load->model("m"); $this->m->username(); // prints john doe $this->m->password(); // prints abc123
now need make in way on can call methds above following:
$this->m->genralinfo->username(); // prints john doe $this->m->privacy->password(); // prints "abc123"
how can achieve ? want in order group methods specific alltogether, helps me structure code better.
**i aware possible create new model every group of methods i'd keep related user inside single model **
is possible using single model ?
i think want this
class m extends ci_model { public $genralinfo; function __construct() { parent::__construct(); $this->genralinfo=new genralinfo(); } } class genralinfo //class genralinfo extends ci_model//you may extend ci_model { public function username() { print "john doe"; } public function password() { print "abc123"; } }
Comments
Post a Comment