From 41986bbc783f007c79df1b508942809a742876d2 Mon Sep 17 00:00:00 2001 From: canyonknight Date: Fri, 25 May 2012 17:45:53 -0400 Subject: rss.php: Pull out DB code * Move DB code in rss.php to new function in aur.inc.php * Centralization of DB code important in a future transition to PDO interface Signed-off-by: canyonknight Signed-off-by: Lukas Fleischer --- web/lib/aur.inc.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'web/lib/aur.inc.php') diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php index 1a294a9..4e6baa2 100644 --- a/web/lib/aur.inc.php +++ b/web/lib/aur.inc.php @@ -533,3 +533,22 @@ function last_insert_id($dbh=NULL) { } return mysql_insert_id($dbh); } + +function latest_pkgs($numpkgs, $dbh=NULL) { + if(!$dbh) { + $dbh = db_connect(); + } + + $q = "SELECT * FROM Packages "; + $q.= "ORDER BY SubmittedTS DESC "; + $q.= "LIMIT " .intval($numpkgs); + $result = db_query($q, $dbh); + + if ($result) { + while ($row = mysql_fetch_assoc($result)) { + $packages[] = $row; + } + } + + return $packages; +} -- cgit v1.2.3-70-g09d2