Welcome Guest, Not a member yet? Register   Sign In
using model and database on libraries
#1

[eluser]adwin[/eluser]
Hi,

I would like to know how to call a model inside a library and how to access database inside the library ?

can the method/function inside controller (let' say it PageOneController.foo() ) called by another Controller (AnotherPageController.bar() ) ?

how to do that

thank you
#2

[eluser]ciGR[/eluser]
You must use the
Code:
$CI =& get_instance();
and after this with $CI variable you can access everything you want, like $this in controllers.
for example
Code:
$CI->load->model('modelname');
$CI->modelname->methos();
...
#3

[eluser]adwin[/eluser]
I tried your example inside the library constructor:

$CI =& get_instance();
$CI->load->library("database");

this produce error ....
Unable to load the requested class: database

any idea why it produce error ?
#4

[eluser]pistolPete[/eluser]
The database class is loaded using: http://ellislab.com/codeigniter/user-gui...cting.html
Code:
$CI->load->database();




Theme © iAndrew 2016 - Forum software by © MyBB