code restructured
This commit is contained in:
19
rename.php
19
rename.php
@@ -18,11 +18,24 @@ if(preg_match(PATTERN, $name) != 1) {
|
||||
$error = 14101;
|
||||
} else if($uid == '') {
|
||||
$error = 14102;
|
||||
} else if($db->query('SELECT EXISTS (SELECT 1 FROM "Users" WHERE "ID" = $1)', array($uid))
|
||||
['data'][0]['exists'] == 'f') {
|
||||
} else if(
|
||||
$db->query(
|
||||
'SELECT EXISTS (
|
||||
SELECT 1
|
||||
FROM "Users"
|
||||
WHERE "ID" = $1
|
||||
)',
|
||||
array($uid)
|
||||
)['data'][0]['exists'] == 'f'
|
||||
) {
|
||||
$error = 14104;
|
||||
} else {
|
||||
$db->query('UPDATE "Users" SET "name" = $1 WHERE "ID" = $2', array($name, $uid));
|
||||
$db->query(
|
||||
'UPDATE "Users"
|
||||
SET "name" = $1
|
||||
WHERE "ID" = $2',
|
||||
array($name, $uid)
|
||||
);
|
||||
if(preg_match('/violates unique constraint "Users_name_unique"/', pg_last_error()) == 1) {
|
||||
$error = 14103;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user