1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

More database fixes

Now able to add feeds to the database
This commit is contained in:
J. King 2017-03-02 22:43:59 -05:00
parent 007e3747ef
commit 2b7a236147
3 changed files with 9 additions and 9 deletions

View file

@ -51,7 +51,7 @@ class Database {
}
public function schemaUpdate(): bool {
if($this->db->schemaVersion() < self::SCHEMA_VERSION) return $this->db->update(self::SCHEMA_VERSION);
if($this->db->schemaVersion() < self::SCHEMA_VERSION) return $this->db->schemaUpdate(self::SCHEMA_VERSION);
return false;
}
@ -163,11 +163,11 @@ class Database {
$value =& $in;
break;
}
$this->db->prepare("REPLACE INTO newssync_settings(key,value,type) values(?,?,?)", "str", (($type=="null") ? "null" : "str"), "str")->run($key, $value, "text");
$this->db->prepare("REPLACE INTO newssync_settings(key,value,type) values(?,?,?)", "str", "str", "str")->run($key, $value, $type);
}
public function settingRemove(string $key): bool {
$this->db->prepare("DELETE from newssync_settings where key = ?", "str")->run($key);
$this->db->prepare("DELETE from newssync_settings where key is ?", "str")->run($key);
return true;
}
@ -182,7 +182,7 @@ class Database {
if($password===null) $password = (new PassGen)->length($this->data->conf->userTempPasswordLength)->get();
$hash = "";
if(strlen($password) > 0) $hash = password_hash($password, \PASSWORD_DEFAULT);
$this->db->prepare("INSERT INTO newssync_users(id,password) values(?,?)", "str", "str")->run($user,$hash);
$this->db->prepare("INSERT INTO newssync_users(id,password) values(?,?)", "str", "str")->runArray([$user,$hash]);
return $password;
}
@ -295,7 +295,7 @@ class Database {
$url,
$feed->title,
// Grab the favicon for the Goodfeed; returns an empty string if it cannot find one.
(new PicoFeed\Reader\Favicon)->find($url),
(new \PicoFeed\Reader\Favicon)->find($url),
$feed->siteUrl,
$feed->date,
$resource->getLastModified(),

View file

@ -19,7 +19,7 @@ interface Driver {
function unlock(): bool;
function isLocked(): bool;
// attempt to perform an in-place upgrade of the database schema; this may be a no-op which always throws an exception
function update(int $to): bool;
function schemaUpdate(int $to): bool;
// execute one or more unsanitized SQL queries and return an indication of success
function exec(string $query): bool;
// perform a single unsanitized query and return a result set

View file

@ -52,11 +52,11 @@ class StatementSQLite3 extends AbstractStatement {
$type = \SQLITE3_TEXT;
}
// cast value if necessary
$value = $this->cast($values[$a], $this->types[$a]);
$values[$a] = $this->cast($values[$a], $this->types[$a]);
// re-adjust for null casts
if($value===null) $type = \SQLITE3_NULL;
if($values[$a]===null) $type = \SQLITE3_NULL;
// perform binding
$this->st->bindParam($a+1, $value, $type);
$this->st->bindParam($a+1, $values[$a], $type);
}
return new ResultSQLite3($this->st->execute(), $this->db->changes(), $this);
}