Saturday, February 16, 2013

Solved:codeigniter how to load library class in model

In one of model file I need to load the library class and use there methods.

After struggling I goan through some articles.
Following article I found useful:
http://ellislab.com/codeigniter/user-guide/libraries/loader.html

Assigning a Library to a different object name

If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if the library is named Session, it will be assigned to a variable named $this->session.

If you prefer to set your own class names you can pass its value to the third parameter: $this->load->library(‘session’, ”, ‘my_session’);

// Session class is now accessed using:

$this->my_session

After this I loaded the Library using following code.

$this->CI = & get_instance();$this->CI->load->library( 'LIB_NAME', '', 'LIB_NAMEInstance' );$RESULT = $this->CI->LIB_NAMEInstance-><wbr />FUNCTION_NAME($PASS_PARAMS);

Source : digcms[dot]com

0 comments:

Post a Comment