From f82e5456d22af7e39a22a9a64e74072cf01e0a31 Mon Sep 17 00:00:00 2001 From: msquare Date: Fri, 28 Jul 2017 20:11:09 +0200 Subject: dried code by introducing selectOne for select queries with only one result line expected --- includes/pages/user_questions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'includes/pages/user_questions.php') diff --git a/includes/pages/user_questions.php b/includes/pages/user_questions.php index e90ea011..e4f35577 100644 --- a/includes/pages/user_questions.php +++ b/includes/pages/user_questions.php @@ -61,11 +61,11 @@ function user_questions() return error(_('Incomplete call, missing Question ID.'), true); } - $question = DB::select( + $question = DB::selectOne( 'SELECT `UID` FROM `Questions` WHERE `QID`=? LIMIT 1', [$question_id] ); - if (count($question) > 0 && $question[0]['UID'] == $user['UID']) { + if (!empty($question) && $question['UID'] == $user['UID']) { DB::delete( 'DELETE FROM `Questions` WHERE `QID`=? LIMIT 1', [$question_id] -- cgit v1.2.3-54-g00ecf