diff options
author | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-04-05 19:32:44 +0200 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-04-05 19:52:51 +0200 |
commit | 122636cbb6413d67c37ba73bd7014ae0a977d5c4 (patch) | |
tree | 85ee0b75844b863ac2283742c3f5f28a9399ebc2 | |
parent | 206678dfb7b1e23b17fc1b4911174054cb24cca5 (diff) |
Refactor pkgbase_comments_count()
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
-rw-r--r-- | web/lib/pkgbasefuncs.inc.php | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index 3bb07e5..24ce7a9 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -25,28 +25,26 @@ function pkgbase_categories() { /** * Get the number of non-deleted comments for a specific package base * - * @param string $pkgid The package base ID to get comment count for + * @param string $base_id The package base ID to get comment count for * * @return string The number of comments left for a specific package */ function pkgbase_comments_count($base_id) { - $dbh = DB::connect(); - $base_id = intval($base_id); - if ($base_id > 0) { - $dbh = DB::connect(); - $q = "SELECT COUNT(*) FROM PackageComments "; - $q.= "WHERE PackageBaseID = " . $base_id; - $q.= " AND DelUsersID IS NULL"; + if (!$base_id) { + return null; } - $result = $dbh->query($q); + $dbh = DB::connect(); + $q = "SELECT COUNT(*) FROM PackageComments "; + $q.= "WHERE PackageBaseID = " . $base_id . " "; + $q.= "AND DelUsersID IS NULL"; + $result = $dbh->query($q); if (!$result) { - return; + return null; } - $row = $result->fetch(PDO::FETCH_NUM); - return $row[0]; + return $result->fetchColumn(0); } /** |