Created
November 21, 2015 18:11
-
-
Save efiku/1d9a562b3a47edee3681 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: efik | |
* Date: 21.11.15 | |
* Time: 18:47 | |
*/ | |
$container = new ArrayObject(); | |
try { | |
$db_1 = new PDO("sqlite:./database_one.sqlite"); | |
$db_2 = new PDO("sqlite:./database_sec.sqlite"); | |
$container->offsetSet("db.shop", $db_1); | |
$container->offsetSet("db.media", $db_2); | |
} catch (PDOException $e) { | |
unset($db_1); | |
unset($db_2); | |
throw $e; | |
} | |
var_dump($container); | |
function dumpUsrs(\PDO $pdo) | |
{ | |
$data = $pdo->query("SELECT id,name,nick,email FROM users"); | |
if ($data) { | |
return json_encode($data->fetchAll()); | |
} | |
return json_encode("Unable to dump users from"); | |
} | |
echo dumpUsrs($container["db.shop"]) . PHP_EOL; | |
echo dumpUsrs($container["db.media"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment