Welcome Guest, Not a member yet? Register   Sign In
CI indepandant Libraries
#4

[eluser]bretticus[/eluser]
Pass those values to the class instead of calling them in the constructor. However in the example you have shown you are using a CI model. Not sure how you'd ever plan on using that class without using the CI framework.
Code:
class TEST_Log{
    var $_ci;
    
    function TEST_Log(){        
        $this->_ci =& get_instance();
        $this->_ci->load->model("Log_model");
    }

    function Log($message = '', $message_type = 'Error' ){
        $this->_ci->Log_model->insertLog($message_type , $message);
    }
}

In other words, if you want the class to be instantiate-able outside of the framework, you cannot use framework objects within the class. I suggest if you need to use database functionality in your uncoupled classes that you instantiate a database connection within that class instead. Otherwise, you can pass variables to classes in CI via the second parameter (see the manual.) And as for any outside-framework code, call it in the usual way (new Object(param,...) )


Messages In This Thread
CI indepandant Libraries - by El Forum - 10-28-2009, 03:06 PM
CI indepandant Libraries - by El Forum - 10-29-2009, 12:13 AM
CI indepandant Libraries - by El Forum - 10-29-2009, 10:44 AM
CI indepandant Libraries - by El Forum - 10-29-2009, 11:57 AM
CI indepandant Libraries - by El Forum - 10-30-2009, 02:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB