summaryrefslogtreecommitdiff
path: root/db.php
diff options
context:
space:
mode:
authorCraig Meyer <[email protected]>2011-08-11 18:51:00 -0400
committerAndrew Dolgov <[email protected]>2011-08-23 12:49:18 +0400
commit147f5632281b0da6f4232b5d8f4e6998ebf1e40b (patch)
tree27abbbe036c7ad5e324482f615fcf0b6f472c1c3 /db.php
parent8efb5f62e86fd0c11147aec979733a33ade53756 (diff)
Extended Actions to include Select by tag (add local modifications, fix
display for tags starting with a number)
Diffstat (limited to 'db.php')
-rw-r--r--db.php22
1 files changed, 13 insertions, 9 deletions
diff --git a/db.php b/db.php
index 9b1ce5d84..81da431b9 100644
--- a/db.php
+++ b/db.php
@@ -3,14 +3,14 @@
require_once "config.php";
function db_connect($host, $user, $pass, $db) {
- if (DB_TYPE == "pgsql") {
-
+ if (DB_TYPE == "pgsql") {
+
$string = "dbname=$db user=$user";
-
+
if ($pass) {
- $string .= " password=$pass";
+ $string .= " password=$pass";
}
-
+
if ($host) {
$string .= " host=$host";
}
@@ -30,10 +30,10 @@ function db_connect($host, $user, $pass, $db) {
} else if (DB_TYPE == "mysql") {
$link = mysql_connect($host, $user, $pass);
if ($link) {
- $result = mysql_select_db($db, $link);
+ $result = mysql_select_db($db, $link);
if (!$result) {
die("Can't select DB: " . mysql_error($link));
- }
+ }
return $link;
} else {
die("Connection failed: " . mysql_error($link));
@@ -44,7 +44,7 @@ function db_connect($host, $user, $pass, $db) {
function db_escape_string($s, $strip_tags = true) {
if ($strip_tags) $s = strip_tags($s);
- if (DB_TYPE == "pgsql") {
+ if (DB_TYPE == "pgsql") {
return pg_escape_string($s);
} else {
return mysql_real_escape_string($s);
@@ -57,7 +57,7 @@ function db_query($link, $query, $die_on_error = true) {
if (!$result) {
$query = htmlspecialchars($query); // just in case
if ($die_on_error) {
- die("Query <i>$query</i> failed [$result]: " . pg_last_error($link));
+ die("Query <i>$query</i> failed [$result]: " . pg_last_error($link));
}
}
return $result;
@@ -131,4 +131,8 @@ function db_last_error($link) {
}
}
+function db_quote($str){
+ return("'$str'");
+}
+
?>