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

  • Home
  • SEARCH
  • 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 8554455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:53:10+00:00 2026-06-11T14:53:10+00:00

so i have been trying to debug this issue myself for a few days

  • 0

so i have been trying to debug this issue myself for a few days now and i can’t seem to figure out why i’m not getting the results I expect.

My code is rather complex and for a DB connection to be establish it spans across 3 Classes and one config file.

but basically my end usage ends up being

$this->db('test')->query('SELECT * FROM test1');

this establishes a connection to my database by the alias of test the query returns results so i’m good so far.

now my issue is when i try to make a new PDO object.

$this->db('test2')->query('SELECT * FROM test2');

this returns nothing because there is not table called test2 in my test1 object.

but if I do this

$this->db('test2')->query('SELECT * FROM test1');

now this returns the same results from the first PDO object.

I have traced and tracked down every line of code to make sure that the correct parameters are being passed to my database class and that each connection is properly established to the corresponding databases.

now my question is, can you have more than one datbase pdo connection? if so is there a special flag that needs to be set in the PDO options? are my connections being cached somewhere and causing this confusion?

this is my PDO declaration in each new class object stored in my array of connections

try
        {
            $this->_con = new PDO(
                "mysql:host=" . $host . ";
                 port=" . $port . ";
                 dbname=" . $name, $user, $pass
            );

            $this->_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        } catch(PDOException $e) {

            // TODO: push all $e methods to the developer debugger
            echo "Database Error: ". $e->getMessage();
        }

edit my code that uses the connection

step 1: a call to the parent class

public function __call($name, $params)
        {
            $class = $name . '_system_helper';
            $hash  = md5($class . $params);

            if (class_exists($class))
            {
                if (!array_key_exists($hash, $this->_sys_helper))
                {
                    if (method_exists($class, 'init'))
                    {
                        $this->_sys_helper[$hash] = call_user_func_array(array($class, 'init'), $params);

                    } else {

                        $this->_sys_helper[$hash] = call_user_func_array($class, $params);
                    }
                }

                return $this->_sys_helper[$hash];
            }

            return null;
        }

step 2: called from the parent class

class DB_System_Helper extends Jinxup
    {
        private $_con = null;

        public function __construct($end = null)
        {
            $mode = null;
            $host = null;
            $name = null;
            $user = null;
            $pass = null;
            $port = null;

            if (isset($this->config['database']['mode']))
            {
                $mode = $this->config['database']['mode'] == 'production' ? 'production' : 'development';

                if (count($this->config['database'][$mode]) > 1)
                {
                    foreach ($this->config['database'][$mode] as $key => $database)
                    {
                        if ($database['@attr']['alias'] == $end)
                        {
                            $host = $this->config['database'][$mode][$key]['host'];
                            $name = $this->config['database'][$mode][$key]['name'];
                            $user = $this->config['database'][$mode][$key]['user'];
                            $pass = $this->config['database'][$mode][$key]['pass'];
                            $port = $this->config['database'][$mode][$key]['port'];
                        }
                    }

                } else {

                    $host = $this->config['database'][$mode]['host'];
                    $name = $this->config['database'][$mode]['name'];
                    $user = $this->config['database'][$mode]['user'];
                    $pass = $this->config['database'][$mode]['pass'];
                    $port = $this->config['database'][$mode]['port'];
                }

                $this->_con = new PDO_Database_Helper($host, $name, $user, $pass, $port);

            } else {

                echo 'No database mode specified';
            }
        }

        public function __call($name, $param)
        {
            return call_user_func_array(array($this->_con, $name), $param);
        }
    }

step 3: called from DB_System_Helper

class PDO_Database_Helper extends Jinxup
{
    private $_con = null;
    private $_id  = 0;

    public function __construct($host, $name, $user, $pass, $port = 3306)
    {
        try
        {
            $this->_con = new PDO(
                "mysql:host=" . $host . ";
                 port=" . $port . ";
                 dbname=" . $name, $user, $pass
            );

            $this->_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        } catch(PDOException $e) {

            // TODO: push all $e methods to the developer debugger
            echo "Database Error: ". $e->getMessage();
        }
    }

        [...]
}
  • 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-11T14:53:11+00:00Added an answer on June 11, 2026 at 2:53 pm

    Are you sure that the hashing you’re doing is enough to “namespace” each connection in the $this->_sys_helper array?

    I suspect the problem lies in the first stage.

        public function __call($name, $params)
        {
            $class = $name . '_system_helper';
            $hash  = md5($class . $params);
    
            if (class_exists($class))
            {
                if (!array_key_exists($hash, $this->_sys_helper))
                {
                    if (method_exists($class, 'init'))
                    {
                        $this->_sys_helper[$hash] = call_user_func_array(array($class, 'init'), $params);
    
                    } else {
    
                        $this->_sys_helper[$hash] = call_user_func_array($class, $params);
                    }
                }
    
      >>>>>>>>>>>>>> are you sure this is not returning the wrong
      >>>>>>>>>>>>>> connection because of how the hashing is working?
                return $this->_sys_helper[$hash];
            }
    
            return null;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to debug this issue for weeks now and I have made
I have been struggling with this problem for a few days now and I
I have been trying it for few days and I do not understand what
I have been trying to optimize an ASP.NET C# application for a few days
I've been trying to debug this for 2 hours and i just can't explain
I have been looking at this for several days now with no success. I
I've been trying to debug this issue for hours upon hours but with no
I have been trying for almost a week now to create an SQLite database
I have been trying to create a ListView which I can sort using drag
Since I posted this question, this issue has resolved itself. There must have been

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.