[aur-dev] [PATCH 1/2] aur.inc: remove unused code
Signed-off-by: Dan McGee <dan@archlinux.org> --- If this is a bogus patch and we do need this code around, let me know. A quick git annotate shows that it is from 2004/2005 and is just old garbage. -Dan web/lib/aur.inc | 47 ----------------------------------------------- 1 files changed, 0 insertions(+), 47 deletions(-) diff --git a/web/lib/aur.inc b/web/lib/aur.inc index 22bd4e7..1fc9842 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -20,53 +20,6 @@ include_once("acctfuncs.inc"); # is using... -# return an array of info for each Trusted user -# -function getTrustedUsers() { - $tus = array(); - $dbh = db_connect(); - $q = "SELECT * FROM Users WHERE AccountTypeID = 2 "; - $q.= "ORDER BY Username ASC"; - $result = db_query($q, $dbh); - if ($result) { - while ($row = mysql_fetch_assoc($result)) { - $tus[$row["ID"]] = $row; - } - } - return $tus; -} - - -# return an array of info for each Developer -# -function getDevelopers() { - $devs = array(); - $dbh = db_connect(); - $q = "SELECT * FROM Users WHERE AccountTypeID = 3 "; - $q.= "ORDER BY Username ASC"; - $result = db_query($q, $dbh); - if ($result) { - while ($row = mysql_fetch_assoc($result)) { - $devs[$row["ID"]] = $row; - } - } - return $devs; -} - -# return an array of info for each user -function getUsers() { - $users = array(); - $dbh = db_connect(); - $q = "SELECT * FROM Users ORDER BY Username ASC"; - $result = db_query($q, $dbh); - if ($result) { - while ($row = mysql_fetch_assoc($result)) { - $users[$row["ID"]] = $row; - } - } - return $users; -} - # see if the visitor is already logged in # function check_sid() { -- 1.6.1
There is really no need to use persistent connections to the database in this day and age. Most PHP development guides recommend against it, and the new mysqli interface doesn't even include the functionality. Add a matching but currently unused db_disconnect() function while we are at it. Reference counting will cover us for the most part, however. Signed-off-by: Dan McGee <dan@archlinux.org> --- web/lib/aur.inc | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/web/lib/aur.inc b/web/lib/aur.inc index 1fc9842..ab52636 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -214,8 +214,7 @@ function uid_from_sid($sid="") { # connect to the database # function db_connect() { - - $handle = mysql_pconnect(AUR_db_host, AUR_db_user, AUR_db_pass); + $handle = mysql_connect(AUR_db_host, AUR_db_user, AUR_db_pass); if (!$handle) { die("Error connecting to AUR database: " . mysql_error()); } @@ -226,15 +225,27 @@ function db_connect() { return $handle; } +# disconnect from the database +# this won't normally be needed as PHP/reference counting will take care of +# closing the connection once it is no longer referenced +# +function db_disconnect($db_handle="") { + if ($db_handle) { + mysql_close($db_handle); + return TRUE; + } + return FALSE; +} + # wrapper function around db_query in case we want to put -# query logging/debuggin in. +# query logging/debugging in. # function db_query($query="", $db_handle="") { if (!$query) { return FALSE; } if (!$db_handle) { - $db_handle = db_connect(); + die("DB handle was not provided to db_query"); } $result = @mysql_query($query, $db_handle); return $result; -- 1.6.1
On Mon, Dec 29, 2008 at 08:46:06PM -0600, Dan McGee wrote:
There is really no need to use persistent connections to the database in this day and age. Most PHP development guides recommend against it, and the new mysqli interface doesn't even include the functionality.
Add a matching but currently unused db_disconnect() function while we are at it. Reference counting will cover us for the most part, however.
Signed-off-by: Dan McGee <dan@archlinux.org> --- web/lib/aur.inc | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-)
Pushed.
On Mon, Dec 29, 2008 at 08:46:05PM -0600, Dan McGee wrote:
Signed-off-by: Dan McGee <dan@archlinux.org> ---
If this is a bogus patch and we do need this code around, let me know. A quick git annotate shows that it is from 2004/2005 and is just old garbage.
Pushed.
participants (2)
-
Dan McGee
-
Loui Chang