3 require_once(
'ppyrd.base.php');
49 $result = $this->db->query($query);
52 $this->
output(
"There was an error in query: $query");
53 $this->
output($this->db->lastErrorMsg());
66 $result = $this->db->exec($query);
69 $this->
output(
"There was an error in query: $query");
71 $this->db->lastErrorMsg());
81 return $this->
query(
"SELECT * FROM rule_archive WHERE isActive = 1");
89 return $this->
query(
"SELECT * FROM rule_senders WHERE isActive = 1");
99 $results = $this->
query(
"SELECT * FROM config WHERE configVariable = '$varname'");
100 if ($results ==
false)
102 $row = $results->fetchArray();
103 return $row[
'configValue'];
114 return $this->
query(
"SELECT * FROM rule_personalInfo WHERE isActive = 1");
123 return $this->
query(
"SELECT * FROM rule_subjects WHERE isActive = 1");
131 return $this->
query(
"SELECT * FROM rule_recipients WHERE isActive = 1");
141 function writeLog($oldName, $newName, $content, $log)
143 $safe = SQLite3::escapeString($content);
144 $this->
exec(
"INSERT INTO logs (oldFileName, newFileName, fileContent, log) VALUES ('$oldName', '$newName', '$safe', '$log');");
153 $this->db =
new SQLite3(
"/data/database/paperyard.sqlite");
154 $this->db->busyTimeout(15000);
157 $this->db->exec(
'PRAGMA journal_mode = wal;');
166 $this->
output(
"looking for DB updates");
169 chdir(
"/www/updates/sqlite/");
172 $updates = glob(
"*.sql");
175 foreach($updates as $update){
177 if ($dbversion ==
false)
179 $version = str_replace(
".sql",
"", $update);
181 if ($version == $dbversion+1) {
182 $this->
output (
"applying " . $update);
183 $this->
output(
"found update script:" . $version);
184 $sql = file_get_contents ($update);
197 $res = $this->db->close();
query($query)
function queries sqlite
writeLog($oldName, $newName, $content, $log)
handling database connection and queries
__construct()
takes care of basic db handling
exec($query)
function executes sqlite
update()
checks if the database schema needs to be updated
close()
closes database connection
output($string, $debug=0)
outputs string
open()
opens database connection or creates file is not found