summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorcanyonknight <canyonknight@gmail.com>2012-05-25 23:45:53 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2012-07-06 11:27:06 +0200
commit41986bbc783f007c79df1b508942809a742876d2 (patch)
treef3f6c7847ebb6eba4099dba9023bd855f846566e /web/lib
parentc15441762c2f6ab4438eaf2854c0ee3146a98b30 (diff)
downloadaur-41986bbc783f007c79df1b508942809a742876d2.tar.gz
aur-41986bbc783f007c79df1b508942809a742876d2.tar.xz
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 <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/aur.inc.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index 1a294a93..4e6baa2d 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;
+}