summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-12-30 03:46:06 +0100
committerLoui Chang <louipc.ist@gmail.com>2008-12-30 19:00:53 +0100
commit3b4662a58e0673de4172e5b0e964c53a0a67af59 (patch)
treeff2c8bda4289fe92c8e87571d0704cd89ffd4d25
parent94bfae4f03991069015566ce7df2699a0c87405f (diff)
downloadaur-3b4662a58e0673de4172e5b0e964c53a0a67af59.tar.gz
aur-3b4662a58e0673de4172e5b0e964c53a0a67af59.tar.xz
Use non-persistant connections
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> Signed-off-by: Loui Chang <louipc.ist@gmail.com>
-rw-r--r--web/lib/aur.inc19
1 files changed, 15 insertions, 4 deletions
diff --git a/web/lib/aur.inc b/web/lib/aur.inc
index 22bd4e72..d4ac7724 100644
--- a/web/lib/aur.inc
+++ b/web/lib/aur.inc
@@ -261,8 +261,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());
}
@@ -273,15 +272,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;