The code below is an attempt to connect more than one database using PHP PDO and SQLite. No matter what I tried, it does not accept the select test1.table1. If I remove the database name the select works; so how do I reference more than one database in the select?
<?php
// connect to SQLite3 database
$query = "test1.sqlite3";
$db = new PDO("sqlite:$query");
// connect to second db
$query = "attach test2.sqlite3";
$db->query($query);
$query = "Select * FROM test1.table1 ";
$result = $db->query($query);
$rows = $result->fetchall(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
echo "<pre>".print_r($row)."</pre>";
}
?>