summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgfuncs.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-02-06 16:11:28 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2014-02-06 18:59:40 +0100
commitc09dcc4e98ec00329c2db43e47fef32121c76312 (patch)
tree01af65f93b9f4bd615fce74c65b5497274f21b9b /web/lib/pkgfuncs.inc.php
parent0722f46c6e5e1a1bae85c24379ff061025679c1d (diff)
downloadaur-c09dcc4e98ec00329c2db43e47fef32121c76312.tar.gz
aur-c09dcc4e98ec00329c2db43e47fef32121c76312.tar.xz
Simplify canDeleteComment()
Use COUNT(*) instead of COUNT(ID) and PDO::FETCH_NUM instead of PDO::FETCH_ASSOC. This also includes some minor formatting fixes. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/pkgfuncs.inc.php')
-rw-r--r--web/lib/pkgfuncs.inc.php20
1 files changed, 10 insertions, 10 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 05be21c0..59cc9756 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -22,19 +22,19 @@ function canDeleteComment($comment_id=0, $atype="", $uid=0) {
/* TUs and developers can delete any comment. */
return true;
}
+
$dbh = DB::connect();
- $q = "SELECT COUNT(ID) AS CNT ";
- $q.= "FROM PackageComments ";
- $q.= "WHERE ID = " . intval($comment_id);
- $q.= " AND UsersID = " . $uid;
+
+ $q = "SELECT COUNT(*) FROM PackageComments ";
+ $q.= "WHERE ID = " . intval($comment_id) . " AND UsersID = " . $uid;
$result = $dbh->query($q);
- if ($result != NULL) {
- $row = $result->fetch(PDO::FETCH_ASSOC);
- if ($row['CNT'] > 0) {
- return true;
- }
+
+ if (!$result) {
+ return false;
}
- return false;
+
+ $row = $result->fetch(PDO::FETCH_NUM);
+ return ($row[0] > 0);
}
/**