mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Finally fix MySQL
This commit is contained in:
parent
e9d449a8ba
commit
2eedf7d38c
1 changed files with 7 additions and 6 deletions
|
@ -320,23 +320,24 @@ class Database {
|
||||||
if (!$this->userExists($user)) {
|
if (!$this->userExists($user)) {
|
||||||
throw new User\ExceptionConflict("doesNotExist", ["action" => __FUNCTION__, "user" => $user]);
|
throw new User\ExceptionConflict("doesNotExist", ["action" => __FUNCTION__, "user" => $user]);
|
||||||
}
|
}
|
||||||
|
$tr = $this->begin();
|
||||||
|
$find = $this->db->prepare("SELECT count(*) from arsse_user_meta where owner = ? and \"key\" = ?", "str", "strict str");
|
||||||
$update = $this->db->prepare("UPDATE arsse_user_meta set value = ? where owner = ? and \"key\" = ?", "str", "str", "str");
|
$update = $this->db->prepare("UPDATE arsse_user_meta set value = ? where owner = ? and \"key\" = ?", "str", "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"];
|
$insert = $this->db->prepare("INSERT INTO arsse_user_meta values(?, ?, ?)", "str", "strict str", "str");
|
||||||
foreach ($data as $k => $v) {
|
foreach ($data as $k => $v) {
|
||||||
if ($k === "admin") {
|
if ($k === "admin") {
|
||||||
$this->db->prepare("UPDATE arsse_users SET admin = ? where id = ?", "bool", "str")->run($v, $user);
|
$this->db->prepare("UPDATE arsse_users SET admin = ? where id = ?", "bool", "str")->run($v, $user);
|
||||||
} elseif ($k === "num") {
|
} elseif ($k === "num") {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
$success = $update->run($v, $user, $k)->changes();
|
if ($find->run($user, $k)->getValue()) {
|
||||||
if (!$success) {
|
$update->run($v, $user, $k);
|
||||||
if (!$insert instanceof Db\Statement) {
|
} else {
|
||||||
$insert = $this->db->prepare(...$insert);
|
|
||||||
}
|
|
||||||
$insert->run($user, $k, $v);
|
$insert->run($user, $k, $v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$tr->commit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue