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 815567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:42:21+00:00 2026-05-15T01:42:21+00:00

Although I can tentatively see a solution to this, I was wondering if there

  • 0

Although I can tentatively see a solution to this, I was wondering if there may be a glaringly obvious simpler approach.

My aim is to use the first segment of a given URI to query the DB as to which controller should be run.

I assume I would have to reform the URI with the resultant controller name in segment 1, then allow the system to continue processing as normal (hence a pre_system hook).

Although not essential I would also like to hold a couple of other variables from the same DB request to be used later in the call stack, and assume this would have to be done using global variables?

Any better suggestions would be gladly received.

Thanks.

  • 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-05-15T01:42:22+00:00Added an answer on May 15, 2026 at 1:42 am

    Should it be of use to anyone else, here is the code to acheive the desired result. This does however not take into account passing additional variables because I can live without them.

    function set_controller()
    {
        include_once APPPATH.'config/database.php'; //Gather the DB connection settings
        $link = mysql_connect($db[$active_group]['hostname'], $db[$active_group]['username'], $db[$active_group]['password']) or die('Could not connect to server.' ); //Connect to the DB server
        mysql_select_db($db[$active_group]['database'], $link) or die('Could not select database.'); //Select the DB
        $URI = explode('/',key($_GET)); //Break apart the URL variable
        $query = 'SELECT * FROM theDomainTable WHERE domainName = "'.$URI[1].'"'; //Query the DB with the URI segment
        if($results = mysql_fetch_array(mysql_query($query))){ //Only deal with controller requests that exist in the database
            $URI[1] = $results['controllerName']; //Replace the controller segment
            $_GET = array(implode('/',$URI)=>NULL); //Reconstruct and replace the GET variable
        }
        mysql_close($link); //Close the DB link
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I seem to be gnawing at this issue, and although I can see how
Although this is FAQ i still couldn't find a suitable solution. I'd like to
Although I can run test.cgi fine but my perl all doesn't work, is this
I'm using Jasmine for some testing, although this can be generally applied to browser-based
When installing Rails 3.0.1 i always get following error message, although i can use
I'm trying to create Configuration : $config = new \Doctrine\ORM\Configuration; Although I can see
Although I can see a lot of discussions around Hibernate and Batch Update, here
This SO answer references Small Boy With A Pattern Syndrome. Although I can infer
I have the following razor template html, although I can't figure out how to
Although obviously not all scenarios can be covered by a single design, is it

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.