I'm trying to read data from the SQLite database which Gmod uses.
I do daily backups and thought it would be efficient to read from a copy of the backup, to retrieve data to display on a site instead of querying the game server itself.
I did try the following to test it out;
[PHP]
if($db = sqlite_open("sv.db")){
print(sqlite_fetch_single(sqlite_query($db, 'A VALID QUERY')));
}[/PHP]
However I keep getting messages saying that the database is encrypted or is not a database.
I access the same database with either Lua, or a SQLite Data browser to execute queries and it returns a result just fine..
Anyone have an idea what's going on?
EDIT:
As the below posts says, Gmod uses SQLite3 which requires PDO, below snippet works fine;
[PHP]$dbh = new PDO('sqlite:/sv.db'); // success
foreach ($dbh->query('A properly escaped query') as $row){
print $row['column'];
}[/PHP]
[URL]http://www.php.net/manual/en/class.pdo.php[/URL]
My guess is that Gmod lua uses SQL lite 3 or higher. PHP SQLite extension only supports SQLite 2 or below. Use PDO instead.
You are correct. Was just coming back to edit my post to those who were curious. :)
Appreciate the help anyway
Sorry, you need to Log In to post a reply to this thread.