CodeIgniter Forums
How to Load a model in my own created library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to Load a model in my own created library (/showthread.php?tid=59382)



How to Load a model in my own created library - El Forum - 09-28-2013

[eluser]Unknown[/eluser]
<?php
class Mylib
{
function show_lib()
{
$obj=& get_instance();
$obj->load->module('login_check');
$var=$obj->login_check->get_all_table_data();
print_r($var);

}
}

?>

ERROR:-
Fatal error: Call to undefined method CI_Loader::module()


How to Load a model in my own created library - El Forum - 09-28-2013

[eluser]noideawhattotypehere[/eluser]
Code:
class Mylib {
    private $CI;

function __construct() {
        $this->CI =& get_instance();
}

function show_lib()
{
    $this->CI->load->model('login_check');
}



}

model/module depending on what you want to do (module if you using HMVC and you want full module loaded in, then use it like $this->CI->login_check->fnc();


How to Load a model in my own created library - El Forum - 09-28-2013

[eluser]Unknown[/eluser]
thanks man..