How I can start a conection inside core/my_router.php?
If I try this:
$this->db->query();
it returns an error.
Is it correct to do this or does CodeIgniter have another method to do this? I have the controller inside a field table row and I need to execute a query to recover it and load the correct controller.
The error is:
Call to a member function query() on a non-object
The Router class is loaded before the CI instance is available which is why you can’t use
$CI =& get_instance()and$CI->db->query(). Calling$this->db->query()and similar methods will only work inside your controllers, models, and views (see user guide).Here is a thread from the CodeIgniter forums that provides a solution to your problem however it is for version 1.7.2 of the framework so you will probably need to make some modifications. Keep in mind you will be editing core files so use caution.
SOLUTION: Database Class / get_instance() in Router.php