Problem -> Acess to CI instance... |
[eluser]n0xie[/eluser]
I understand the (textbook) theory behind using static methods: that was not the question. The question was, why you would want to use them here (within Code Igniter). CI uses 1 super object to which it binds all the other objects. This way you don't have to pass objects around, instead you can reference all your objects through the CI super object. You may want to read up on how Code Igniter works. Try this article: http://www.packtpub.com/article/codeigniter-and-objects. Usually while writing software you want to keep the object instantiating to a minimum since they cost memory, but since PHP 'forgets' everything after parsing a script, there is really no cost penalty for instantiating every model (well obviously there is but it's minimal). If you want a more modular approach you might want to take a look at the Zend framework. Of course CI does allow you to call static methods but there really isn't a benefit I can think off (plus you lose all the references to the CI super object inside this scope). Just don't use the $this->load syntax but instead include your class and call it manually like you would do 'the normal way'. Code: include ('somepath/someclass.php'); |
Messages In This Thread |
Problem -> Acess to CI instance... - by El Forum - 06-17-2009, 07:12 PM
Problem -> Acess to CI instance... - by El Forum - 06-17-2009, 09:46 PM
Problem -> Acess to CI instance... - by El Forum - 06-18-2009, 04:19 AM
Problem -> Acess to CI instance... - by El Forum - 06-18-2009, 04:54 AM
Problem -> Acess to CI instance... - by El Forum - 06-18-2009, 05:16 AM
Problem -> Acess to CI instance... - by El Forum - 06-18-2009, 05:36 AM
Problem -> Acess to CI instance... - by El Forum - 06-18-2009, 05:39 AM
Problem -> Acess to CI instance... - by El Forum - 06-18-2009, 05:43 AM
Problem -> Acess to CI instance... - by El Forum - 06-18-2009, 06:06 AM
Problem -> Acess to CI instance... - by El Forum - 06-18-2009, 06:09 AM
Problem -> Acess to CI instance... - by El Forum - 06-18-2009, 06:45 AM
|