about summary refs log tree commit diff stats
path: root/include/functions.php
diff options
context:
space:
mode:
authorAndrew Dolgov <noreply@fakecake.org>2017-02-25 00:27:31 +0300
committerAndrew Dolgov <noreply@fakecake.org>2017-02-25 00:27:31 +0300
commit885224d569d535b7e63ab301e4fd6cdc71c5c49b (patch)
tree30316ac1023460a53b9920e61f11f10fa87f56d0 /include/functions.php
downloadthe-epube-885224d569d535b7e63ab301e4fd6cdc71c5c49b.tar.gz
the-epube-885224d569d535b7e63ab301e4fd6cdc71c5c49b.tar.xz
initial
Diffstat (limited to 'include/functions.php')
-rw-r--r--include/functions.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/functions.php b/include/functions.php
new file mode 100644
index 0000000..9563190
--- /dev/null
+++ b/include/functions.php
@@ -0,0 +1,26 @@
+<?php
+	require_once "db.php";
+
+	function init_connection($link) {
+
+		if (!$link) {
+			if (DB_TYPE == "mysql") {
+			print mysql_error();
+		}
+		// PG seems to display its own errors just fine by default.
+			die("Connection failed.");
+		}
+
+		if (DB_TYPE == "pgsql") {
+			pg_query($link, "set client_encoding = 'UTF-8'");
+			pg_set_client_encoding("UNICODE");
+			pg_query($link, "set datestyle = 'ISO, european'");
+			pg_query($link, "set time zone '".DB_TIMEZONE."'");
+		} else {
+			if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
+				db_query($link, "SET NAMES " . MYSQL_CHARSET);
+	//			db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
+			}
+		}
+	}
+