diff options
author | canyonknight <canyonknight@gmail.com> | 2012-05-23 21:18:36 +0200 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2012-07-06 11:26:50 +0200 |
commit | 09e50568e41a470093486dbd20f3aa4f4da08444 (patch) | |
tree | 3f268cccf8d4c3fe085d2c0fcbd762bffa7fafe9 /web/lib/pkgfuncs.inc.php | |
parent | 091c2b5f5523773604699b914c19e6b02ce290bc (diff) | |
download | aur-09e50568e41a470093486dbd20f3aa4f4da08444.tar.gz aur-09e50568e41a470093486dbd20f3aa4f4da08444.tar.xz |
voters.php: Pull out DB code
* Create new function in pkgfuncs.inc.php with SQL queries from voters.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/pkgfuncs.inc.php')
-rw-r--r-- | web/lib/pkgfuncs.inc.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index 0d4fe8c8..5696321f 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -948,6 +948,31 @@ function pkg_vote ($atype, $ids, $action=true, $dbh=NULL) { } } +# Get all usernames and ids for a specifc package id +function getvotes($pkgid, $dbh=NULL) { + if(!$dbh) { + $dbh = db_connect(); + } + + $pkgid = db_escape_string($pkgid); + + $q = "SELECT UsersID,Username FROM PackageVotes "; + $q.= "LEFT JOIN Users on (UsersID = ID) "; + $q.= "WHERE PackageID = ". $pkgid . " "; + $q.= "ORDER BY Username"; + $result = db_query($q, $dbh); + + if (!$result) { + return; + } + + while ($row = mysql_fetch_assoc($result)) { + $votes[] = $row; + } + + return $votes; +} + /** * Toggle notification of packages * |