Re: Multiple Database Connection Using Prepard Statements

Matijn Woudt <[email protected]>
Newsgroups gmane.comp.php.database
Message-ID <CAC_gtuMKvDSNqYXmCTbV9sOhsGZ6wPXAQ5CupyyW4Jj=c+a1Dw@mail.gmail.com>
On Sat, May 19, 2012 at 8:36 PM, Ron Piggott
<[email protected]> wrote:
>
> How do I connect to multiple mySQL databases using Prepared Statements ?
>
> I have the syntax
>
> ===
> $dsh = 'mysql:host=localhost;dbname='.$database3;
> $dbh = new PDO($dsh, $username, $password);
> ===
>
> I want to connect to $database1 without loosing my $database3 connection
>

$dsh = 'mysql:host=localhost;dbname='.$database3;
$dbh = new PDO($dsh, $username, $password);
$dsh2 = 'mysql:host=localhost;dbname='.$database1;
$dbh2 = new PDO($dsh2, $username2, $password2);

Now you can use $dbh for $database3, and $dbh2 for $database1...

- Matijn

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.