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)) {
|
||||
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");
|
||||
$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) {
|
||||
if ($k === "admin") {
|
||||
$this->db->prepare("UPDATE arsse_users SET admin = ? where id = ?", "bool", "str")->run($v, $user);
|
||||
} elseif ($k === "num") {
|
||||
continue;
|
||||
} else {
|
||||
$success = $update->run($v, $user, $k)->changes();
|
||||
if (!$success) {
|
||||
if (!$insert instanceof Db\Statement) {
|
||||
$insert = $this->db->prepare(...$insert);
|
||||
}
|
||||
if ($find->run($user, $k)->getValue()) {
|
||||
$update->run($v, $user, $k);
|
||||
} else {
|
||||
$insert->run($user, $k, $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
$tr->commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue