Added DB_DSN

This commit is contained in:
Savetheinternet 2010-12-18 02:24:27 +11:00
parent ebed5b55db
commit 796a544560
2 changed files with 8 additions and 2 deletions

View File

@ -11,7 +11,8 @@
// Database stuff
// "mysql", "pgsql", etc
// SQL driver ("mysql", "pgsql", "sqlite", "dblib", etc)
// http://www.php.net/manual/en/pdo.drivers.php
define('DB_TYPE', 'mysql', true);
// Hostname or IP address
define('DB_SERVER', 'localhost', true);
@ -20,6 +21,8 @@
define('DB_PASSWORD', '', true);
// TinyBoard database
define('DB_DATABASE', '', true);
// Anything more to add to the DSN string (eg. port=xxx;foo=bar)
define('DB_DSN', '', true);
// The name of the session cookie (PHP's $_SESSION)
define('SESS_COOKIE', 'imgboard', true);

View File

@ -4,8 +4,11 @@
global $pdo;
if($pdo) return true;
$dsn = DB_TYPE . ':host=' . DB_SERVER . ';dbname=' . DB_DATABASE;
if(!empty($dsn))
$dsn .= ';' . DB_DSN;
try {
return $pdo = new PDO(DB_TYPE . ':host=' . DB_SERVER . ';dbname=' . DB_DATABASE, DB_USER, DB_PASSWORD);
return $pdo = new PDO($dsn, DB_USER, DB_PASSWORD);
} catch(PDOException $e) {
$message = $e->getMessage();