Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8436767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:16:18+00:00 2026-06-10T07:16:18+00:00

I want to access database functions in extending libraries. class My_Router extends CI_Router {

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:16:20+00:00Added an answer on June 10, 2026 at 7:16 am

    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 require ing the system/DB.php and use the DB() function to get an instance of the db class.

    public function _set_routing(){
        require_once BASEPATH.'database/DB.php';
        $db = DB('default', true); // you can set the database.php config's group, or a full DSN string here
        $custom_routes = $db->get('custome_routes')->result_array();
    }
    

    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).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database repository with a bunch of access functions. I now want
I want to use Access database with query for pivot table in Excel. How
I want to access a MySQL database and I want to read+write data from+to
I want to access a MySQL database from Java, but remote connection is disabled
I have this old Access database (2000 format) which i want to convert to
I want to insert a date record to an Access database. Here is my
I want to give permission to a user to access my database using work
I want to make a Windows service that will access my database. My database
I'm using Linq to SQL to access my database. I want to have a
Good night, in my application I access my database through Hibernate. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.