Re: Prepared Statements With Multiple Databases

From: Date: Sat, 01 Oct 2011 01:34:07 +0000
Subject: Re: Prepared Statements With Multiple Databases
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-48016@lists.php.net to get a copy of this message
On 2011-09-30, at 8:26 PM, "Ron Piggott" <ron.piggott@actsministries.org> wrote: > > I need my Prepared Statement database connection to be able to connect with two different > databases (which use the same username / password). > > They are assigned variables > > $database1 and $database2 > > What I have been using so far is: > > > $dsh = 'mysql:host=localhost;dbname='. $database1; > $dbh = new PDO($dsh, $username, $password); > > > Is there a way to amend this with a second database connection? > > Ron > > > > www.TheVerseOfTheDay.info A simpler option maybe to use the dbname.tablename syntax to donthe query Select db1.somefield, db1.anotherfield... Select db2.somefield, db2.someotherfield Bastien Koert 905-904-0334

« previous php.db (#48016) next »