I'm attempting to do a test accessing multiple databases with the code listed
below.
It errors on the 2nd db select statement and says that the "table does not
exist".
I am using 2 identical db for the test with different names. Any idea what I
am
doing wrong? - Thanks, Jan Zumwalt

<?php
  echo '<body style="font-family:arial;">';
  echo '<h2>Use Multiple Database</h2>';
 
  $db = new PDO("sqlite:db1.sqlite3"); // db connect
  $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //enhanced
error msg
 
# query using simple SELECT
  $result = $db->query("SELECT * FROM 'sales'");
  $rows   = $result->fetchall(PDO::FETCH_ASSOC);
  echo "<pre>"; print_r($rows); echo "</pre>";

# attach second database
  $result = $db->query("ATTACH database 'db2.sqlite3' AS lastyear");
 
# query 2nd database
  $result = $db->query('SELECT * FROM lastyear.sales'); // <== ERRORS
  $rows   = $result->fetchall(PDO::FETCH_ASSOC);
  echo "<pre>"; print_r($rows); echo "</pre>"; 
?>
-- 
View this message in context: 
http://old.nabble.com/accessing-multiple-databases-tp33410065p33410065.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to