Welcome Guest, Not a member yet? Register   Sign In
Couple of question about libraries
#1

[eluser]rvent[/eluser]
I have a library vg_ldap_auth and another one vg_suite. I want my controller to interact directly with vg_suite and let vg_suite be the gateway to vg_ldap_auth. Is the only way of loading vg_ldap_auth into vg_suite to do $CI =& get_instance() and then load it..?

The second question is about inheritance, let's say i have a file vg_person.php and a class vg_person in it, then i have another file vg_person_girl.php with a class vg_person_girl and i would like vg_person_girl to extend vg_person. So do
Code:
class Vg_person_girl extends Vg_person
{
   __construct()
   {
      //some stuff here
   }

   function so_something()
   {
     //does something
   }
}

But i keep getting errors about "class Vg_person" doesnt exist in file... Do i need to do include(vg_person) and then access its members with parant:Confusedomething or does CI provides a way of doing this...?

Thanks
#2

[eluser]TheFuzzy0ne[/eluser]
[quote author="rvent" date="1234385572"]I have a library vg_ldap_auth and another one vg_suite. I want my controller to interact directly with vg_suite and let vg_suite be the gateway to vg_ldap_auth. Is the only way of loading vg_ldap_auth into vg_suite to do $CI =& get_instance() and then load it..?[/quote]

No. You can just include/require it if you want. If you load it through CodeIgniter's loader it will be instantiated for you, but if you don't need to access that class directly, I would suggest a simple require_once();

[quote author="rvent" date="1234385572"
But i keep getting errors about "class Vg_person" doesnt exist in file... Do i need to do include(vg_person) and then access its members with parant:Confusedomething or does CI provides a way of doing this...?

Thanks[/quote]

Just require_once() vg_person.php, and then you can manually instantiate vg_person_girl or have CodeIgniter load it for you and instantiate it.

Once it's instantiated, then it will be extending Vg_person. You can access members with the $this keyword, unless you've overridden the function and need access to it, in which case you will need to use parent::function/variable_name.




Theme © iAndrew 2016 - Forum software by © MyBB