Re: Multiple Database Connection Using Prepard Statements
| From: | Matijn Woudt | Date: | Sat, 19 May 2012 22:42:29 +0000 |
| Subject: | Re: Multiple Database Connection Using Prepard Statements | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-48288@lists.php.net to get a copy of this message | ||
On Sat, May 19, 2012 at 8:36 PM, Ron Piggott
<ron.piggott@actsministries.org> 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