Welcome Guest, Not a member yet? Register   Sign In
Question about calling a library from within a library
#2

[eluser]Jelmer[/eluser]
Alternative:
Code:
class MY_Form_validation extends CI_Form_validation {

    var $ion_auth;
      
    function My_Form_Validation()
    {
        parent::CI_Form_Validation();

        $CI =& get_instance();
        $CI->load->library('ion_auth');
        $this->ion_auth = $CI->ion_auth;
    }
    
    function username_check($username)
    {
        return ($this->ion_auth->username_check($username) ? FALSE : TRUE);
    }
}

Second alternative (changes only this method from your code):
Code:
function username_check($username)
    {
        get_instance()->load->library('ion_auth');
        return (get_instance()->ion_auth->username_check($username) ? FALSE : TRUE);
    }

Bottom line: nothing is "wrong", my preference used to be to use the first alternative. Nowadays I use either the second example or use a helper I wrote that allows usage like Ci::lib('ion_auth') and autoload if the lib wasn't loaded yet (AugmentedCI helper).


Messages In This Thread
Question about calling a library from within a library - by El Forum - 09-30-2010, 04:30 PM
Question about calling a library from within a library - by El Forum - 09-30-2010, 05:12 PM
Question about calling a library from within a library - by El Forum - 09-30-2010, 05:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB