diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2015-05-21 17:08:58 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2015-05-21 17:10:33 +0200 |
commit | 01bfae82ce90e5f98180fb920479ed72977c0385 (patch) | |
tree | d82ad3d3e6ecf06b59212c32e00841e442e2965b /web/lib/pkgreqfuncs.inc.php | |
parent | c3614c4f097f1a37485672b04759c5c163f1cf42 (diff) |
Make the type parameter of pkgreq_by_pkgbase() optional
This simplifies the code a bit, improves maintainability and reduces the
number of SQL queries when deleting a package.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib/pkgreqfuncs.inc.php')
-rw-r--r-- | web/lib/pkgreqfuncs.inc.php | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php index e4c63b5..c056d68 100644 --- a/web/lib/pkgreqfuncs.inc.php +++ b/web/lib/pkgreqfuncs.inc.php @@ -49,15 +49,18 @@ function pkgreq_list($offset, $limit) { * * @return array List of package request IDs */ -function pkgreq_by_pkgbase($baseid, $type) { +function pkgreq_by_pkgbase($baseid, $type=false) { $dbh = DB::connect(); $q = "SELECT PackageRequests.ID "; $q.= "FROM PackageRequests INNER JOIN RequestTypes ON "; $q.= "RequestTypes.ID = PackageRequests.ReqTypeID "; $q.= "WHERE PackageRequests.Status = 0 "; - $q.= "AND PackageRequests.PackageBaseID = " . intval($baseid) . " "; - $q.= "AND RequestTypes.Name = " . $dbh->quote($type); + $q.= "AND PackageRequests.PackageBaseID = " . intval($baseid); + + if ($type) { + $q .= " AND RequestTypes.Name = " . $dbh->quote($type); + } return $dbh->query($q)->fetchAll(PDO::FETCH_COLUMN, 0); } |