summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2021-10-03 22:02:29 -0400
committerSolomon Peachy <pizza@shaftnet.org>2021-10-04 20:49:19 -0400
commite20a3ac71fd14ab916f0e7ec5f83400873ab8494 (patch)
tree297abe7a970bc8c4c909bd72417fd37966413471
parent571de2af2d0688a420115d4cd9e2e1ed8775ee33 (diff)
downloadthemesite-e20a3ac71fd14ab916f0e7ec5f83400873ab8494.tar.gz
themesite-e20a3ac71fd14ab916f0e7ec5f83400873ab8494.zip
themesite: Migrate to using PDO for DB access
Still using sqlite, but it's PDO-based, so we can switch to a real DB.
-rw-r--r--private/db.class.php16
1 files changed, 8 insertions, 8 deletions
diff --git a/private/db.class.php b/private/db.class.php
index b04750e..857042e 100644
--- a/private/db.class.php
+++ b/private/db.class.php
@@ -78,7 +78,7 @@ class db {
public function __construct($file) {
$this->file = $file;
/* open db */
- $this->dh = new SQLite3($file);
+ $this->dh = new PDO("sqlite:$file", "", "");
}
public function query($sql, $args = null){
@@ -94,12 +94,12 @@ class db {
$res = $stmt->execute();
//check for errors
if($res === false){
- $code = $this->dh->lastErrorCode();
- $err = sprintf('%s (%d)', $this->dh->lastErrorMsg(), $code);
+ $code = $this->dh->errorCode();
+ $err = sprintf('%s (%d)', $this->dh->errorInfo(), $code);
$sql = $sql . ' ' . print_r($args, true);
$this->error($err, $sql);
- }else{
- return new result($res, $this->dh);
+ } else{
+ return new result($stmt, $this->dh);
}
}
@@ -152,7 +152,7 @@ class result {
}
public function next($field = false) {
- $row = $this->rh->fetchArray(SQLITE3_ASSOC);
+ $row = $this->rh->fetch();
if ($field !== false && isset($row[$field])) {
return $row[$field];
} else {
@@ -161,11 +161,11 @@ class result {
}
public function insertid() {
- return $this->dh->lastInsertRowID();
+ return $this->dh->lastInsertId();
}
public function rowsaffected() {
- return $this->dh->changes();
+ return $this->rh->rowCount();
}
}