PHP Classes

PDO Multiple Connections with Global Instance

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  PDO Multiple Connections with Global...  
Subject:PDO Multiple Connections with Global...
Summary:How to create a single conection for each database ?
Messages:1
Author:Paulo Lima
Date:2014-08-31 12:07:58
Update:2014-08-31 18:54:37
 

  1. PDO Multiple Connections with Global...   Reply   Report abuse  
Picture of Paulo Lima Paulo Lima - 2014-08-31 18:54:37
I've a system that supports many connections with many databases, like:

Conn1 = mysql = database1; (master)
Conn2 = mssql = database2;
Conn3 = oracle = database3;

I check the connection to each table of my system (which are controlled by a data dictionary on master connection) so I can point it to the right connection.

I managed to get it working but every time I reload a page the system creates a new connection based on my connection ID, i would like to create 3 PDO instances that could be accessed globally.

My web site is working inside a master page with menus that load into an iFrame, the connections are used inside this iFrame, so every time I send an information to the iFrame, it kills every instance of my previously PDO instance causing a major performance problem.

I tried creating a session to PDO but i get fatal error from PHP that says: Cannot serialize PDO.

Any ideas?