-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.db.php
More file actions
56 lines (48 loc) · 1.29 KB
/
class.db.php
File metadata and controls
56 lines (48 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
class LetterAdsDB extends SQLite3
{
var $result, $row;
public function __construct()
{
$this->open('ad_tool_db.db');
$this->exec("CREATE TABLE IF NOT EXISTS utility_table (
id INTEGER PRIMARY KEY AUTOINCREMENT,
utility_name STRING,
bill_date STRING)"
);
}
public function execsql($asql) {
// use a prepared statement instead for insert/replace/delete
$statement = $this->prepare($asql);
$this->result = $statement->execute();
if (!$this->result) {
try {
$error = 'There was an error:\n';
throw new Exception($this->lastErrorMsg());
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
// Continue execution
echo 'Something executed incorrectly and there\'s nobody to blame.';
} else {
return $this->result;
}
}
public function fetchsql($asql){
$result = $this->query($asql);
$this->row = $result->fetchArray();
if (!$this->row) {
try {
$error = 'There was an error:\n';
throw new Exception($this->lastErrorMsg());
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
// Continue execution
echo 'Something executed incorrectly and there\'s nobody to blame.';
} else {
return $this->row;
}
}
}
?>