rendered paste body----- SQlite.class.php -----
<?php
/*
* Copyright © Malcolm Jarvis
* This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 license.
* For more details, see http://creativecommons.org/licenses/by-nc-sa/3.0/
*/
class SQlite
{
public function __construct()
{
$this->db = new SQLiteDatabase('data/prefs.sqlite');
$this->Install();
}
private function Install()
{
$this->db->queryExec("
CREATE TABLE IF NOT EXISTS `prefs`
( `name` TEXT UNIQUE KEY,
`value` TEXT )
");
}
public function GetPreference($name)
{
$name = sqlite_escape_string($name);
var_dump($this->db->singleQuery("SELECT `value` FROM `prefs` WHERE `name`='$name'"));
}
public function Preference($name, $value)
{
$name = sqlite_escape_string($name);
$value = sqlite_escape_string($value);
$this->db->queryExec("INSERT OR REPLACE INTO `prefs` (`name`,`value`) VALUES ('$name', '$value')");
}
}
$test = new SQlite;
?>
----- Errors after running with php5 binary -----
Fatal error: Uncaught exception 'SQLiteException' with message 'SQLiteDatabase::__construct(): unable to open database: /Users/malcolm/Sites/Scripts/BigBlueHouse/svn/remote/lib/data/prefs.sqlite' in /Users/malcolm/Sites/Scripts/BigBlueHouse/svn/remote/lib/SQLite.class.php:12
Stack trace:
#0 /Users/malcolm/Sites/Scripts/BigBlueHouse/svn/remote/lib/SQLite.class.php(12): SQLiteDatabase->__construct('data/prefs.sqli...')
#1 /Users/malcolm/Sites/Scripts/BigBlueHouse/svn/remote/lib/SQLite.class.php(39): SQlite->__construct()
#2 {main}
thrown in /Users/malcolm/Sites/Scripts/BigBlueHouse/svn/remote/lib/SQLite.class.php on line 12