From ce68566fcb8d235e75ad048cb2ee6ab5d400d0a2 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sun, 6 Dec 2020 20:27:20 -0500 Subject: [PATCH] Hopefully fix MySQL --- lib/Database.php | 2 +- lib/Db/MySQL/Statement.php | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/Database.php b/lib/Database.php index f01338a..ecf1ede 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -321,7 +321,7 @@ class Database { throw new User\ExceptionConflict("doesNotExist", ["action" => __FUNCTION__, "user" => $user]); } $update = $this->db->prepare("UPDATE arsse_user_meta set value = ? where owner = ? and \"key\" = ?", "str", "str", "str"); - $insert = ["INSERT INTO arsse_user_meta values(?, ?, ?)", "str", "strict str", "str"]; + $insert = ["INSERT INTO arsse_user_meta select ?, ?, ? where not exists(select 1 from arsse_user_meta where owner = ? and \"key\" = ?)", "str", "strict str", "str", "str", "strict str"]; foreach ($data as $k => $v) { if ($k === "admin") { $this->db->prepare("UPDATE arsse_users SET admin = ? where id = ?", "bool", "str")->run($v, $user); diff --git a/lib/Db/MySQL/Statement.php b/lib/Db/MySQL/Statement.php index aba3542..057225a 100644 --- a/lib/Db/MySQL/Statement.php +++ b/lib/Db/MySQL/Statement.php @@ -84,11 +84,7 @@ class Statement extends \JKingWeb\Arsse\Db\AbstractStatement { } // create a result-set instance $r = $this->st->get_result(); - if (preg_match("\d+", mysqli_info($this->db), $m)) { - $changes = (int) $m[0]; - } else { - $changes = 0; - } + $changes = $this->st->affected_rows; $lastId = $this->st->insert_id; return new Result($r, [$changes, $lastId], $this); }