CodeIgniter Forums
load->model call constructor. I don't need it - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: load->model call constructor. I don't need it (/showthread.php?tid=17338)



load->model call constructor. I don't need it - El Forum - 04-02-2009

[eluser]MDomansky[/eluser]
Hi,

$this->load->model('user');

CI call constructor of user class and it will be available by $this->user. I don't need it.

How can I determine when I want to run constructor?

Thanks in advice


load->model call constructor. I don't need it - El Forum - 04-02-2009

[eluser]TheFuzzy0ne[/eluser]
I don't understand... The constructor is called automatically by PHP when an object is instantiated. If you have things that need doing "after" instantiation, you'd probably be better of putting the code in a method called "init", or "initialize" and calling that when you want to.


load->model call constructor. I don't need it - El Forum - 04-02-2009

[eluser]MDomansky[/eluser]
I have meant about parameters for constructor.

I want to run constructor with parameters I give.
$u = new user(1, TRUE);

How can I do it through CI?

PS: sorry for my english


load->model call constructor. I don't need it - El Forum - 04-02-2009

[eluser]Dreammaker[/eluser]
I think if you need load configs it make sense to use a library instead model.

Or you can use some method for loading parameters after initialization.

<offtop>
Я так подозреваю тут для большей половины английский не родной и все боятся чтобы не попалили Big Grin
</offtop>