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
Post a Comment