1. Go to this page and download the library: Download siteparts/pdoconnections library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
siteparts / pdoconnections example snippets
use PDO;
use SiteParts\Database\Pdo\Connections;
$dbConfig = [
'default' => [
'dsn' => 'mysql:dbname=foo;host=server1;charset=utf8',
'username' => 'john',
'password' => 'secret1',
'attributes' => [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
],
],
'bar' => [
'dsn' => 'mysql:dbname=bar;host=server2;charset=utf8',
'username' => 'jack',
'password' => 'secret2',
],
];
$connections = new Connections($dbConfig);
$defaultDb = $connections->getConnection(); // $defaultDb is PDO
$barDb = $connections->getConnection("bar"); // $barDb is PDO
// Subsequent calls return already existing connection
$db = $connections->getConnection("bar"); // $db is the same as $barDb
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.