From 44268778c824c2d5f49f00f9276a864aeb2e9681 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 29 May 2014 21:13:27 +0200 Subject: Move latest_pkgs() to pkgfuncs.inc.php Signed-off-by: Lukas Fleischer --- web/lib/pkgfuncs.inc.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'web/lib/pkgfuncs.inc.php') diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index c35147f..a43512c 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -942,3 +942,27 @@ function pkg_add_lic($pkgid, $licid) { ); $dbh->exec($q); } + +/** + * Determine package information for latest package + * + * @param int $numpkgs Number of packages to get information on + * + * @return array $packages Package info for the specified number of recent packages + */ +function latest_pkgs($numpkgs) { + $dbh = DB::connect(); + + $q = "SELECT * FROM Packages "; + $q.= "ORDER BY SubmittedTS DESC "; + $q.= "LIMIT " .intval($numpkgs); + $result = $dbh->query($q); + + if ($result) { + while ($row = $result->fetch(PDO::FETCH_ASSOC)) { + $packages[] = $row; + } + } + + return $packages; +} -- cgit v1.2.3-70-g09d2