I want to access database functions in extending libraries.
class My_Router extends CI_Router {
public function __construct()
{
parent::__construct();
}
function _set_routing()
{
.....
....
$query=$this->db->get('custome_routes');
$custom_routes=$query->result_array();
....
}
}
I tried below also
$CI =& get_instance();
$query=$CI->db->get('custome_routes');
$custom_routes=$query->result_array();
But it doesn’t work.
Help me….
Thanks in advance,
Logan
Unfortunately you can’t do that, because the loading order of the framework, and since the routing information is used to decide what controller class to load, and the return value of
get_instance()is that controller instance.You can try using CI’s built in class by
requireing the system/DB.php and use theDB()function to get an instance of the db class.Or you could make a CI independent db connection in your subclass, for this one “get the full table” query this shouldn’t be hard. You should be able to include the CI database config file and use it’s values without problems (watch out for environments).