Reputation: 479
Couple questions. Whats the best way to access a live .db file using sqlite to just read data?
Secondly
$url = "data.db";
try
{
$db = new PDO('sqlite:"$url"');
...
How can I correct this syntax so I can set the database url as a variable? If I must use a different method other than PDO because of question 1 please set it out with a variable for database url.
Thanks
Upvotes: 4
Views: 2956
Reputation:
Shamelessly taken from Opening SQLite3 as READONLY with PDO?:
Instead of PDO, try the SQLite3 library:
$db = new SQLite3($url, SQLITE3_OPEN_READONLY);
For more details, refer to PHP's doc:
http://php.net/manual/en/sqlite3.open.php
Upvotes: 3