php - Is there anyway to pass in a variable in constructor when loading a model? -


i trying load model, , pass in variable in constructor couldn't find solution achieve this. have solution issue? below code. thanks!

    $this->load->model(["client/hiredfreelancers_model"]); 

model file

class hiredfreelancers_model extends ci_model {      private $proj_id;      public function __construct($proj_id)     {         $this->proj_id = $proj_id;     } } 

you can not this. far know not go along mvc model.

one question is: need model or create library instead?

a solution use init-function call after loading model. better mvc approach pass parameter when calling functions on loaded model.

this answered question might too: codeigniter: how pass variables model while loading


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -