Are you sure it's really opening the DB you think it's opening? I think SQLite will create the file if it's not there, and you'll have nothing in it.
Perhaps you should try it and specify the complete path, just in case. I don't know if the PDO object looks for the file before opening it. Marc > -----Original Message----- > From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- > boun...@sqlite.org] On Behalf Of jwzumwalt > Sent: Tuesday, February 28, 2012 5:05 PM > To: sqlite-users@sqlite.org > Subject: [sqlite] accessing multiple databases > > > 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 _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users