Welcome Guest, Not a member yet? Register   Sign In
[Q] where can I declare a class to share between library, controllers
#2

[eluser]vlad_ci[/eluser]
Well, probably my question was too basic so did not get any replies.

This is what I did and it seems to suite my primitive needs sofar.

Basically in my controller before declaring my controller class,
I did this

Code:
function __autoload ($cname)
{
    require_once(APPPATH.'libraries/CCommonData.php');
}

I saw many examples people attempting to have a 'generic'
autoloader that would search for certain paths/etc depending
on the class name $cname to autoload.

But all I wanted to do is to emulate C++ include files --
where I can have many classes declared within one include
(and this seems to let me do that). I put those things in the library
directory even though I do not plan to use CI->load->library
(for the reason explained in my original post).


This __autoload construct apparently also improves performance
as when I have more and more files being used during the Controller
processing -- it will automagically execute my require_once only
if a given has not been declared yet.

Wanted to hear if people have any comments on the above.
(this is PHP5 only, I believe)

Thanks in advance


Messages In This Thread
[Q] where can I declare a class to share between library, controllers - by El Forum - 09-08-2008, 11:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB