Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter: How can I create a new instance of a library whenever the method is called?
#4

[eluser]pistolPete[/eluser]
Have a look at the loader class, it's pretty self-explanatory:
Code:
/* Location: ./system/libraries/Loader.php */
/* line 767 and following */      
          
                 // Safety:  Was the class already loaded by a previous call?
                if (in_array($filepath, $this->_ci_loaded_files))
                {
                    // Before we deem this to be a duplicate request, let's see
                    // if a custom object name is being supplied.  If so, we'll
                    // return a new instance of the object
                    if ( ! is_null($object_name))
                    {
                        $CI =& get_instance();
                        if ( ! isset($CI->$object_name))
                        {
                            return $this->_ci_init_class($class, '', $params, $object_name);
                        }
                    }
                
                    $is_duplicate = TRUE;
                    log_message('debug', $class." class already loaded. Second attempt ignored.");
                    return;
                }

--> If you don't use the third parameter, no new instances will be created.


Messages In This Thread
CodeIgniter: How can I create a new instance of a library whenever the method is called? - by El Forum - 10-07-2009, 03:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB