diff --git a/browse.php b/browse.php index a49c851..29f3750 100644 --- a/browse.php +++ b/browse.php @@ -24,7 +24,7 @@ require('header.php'); '; var_export($results); echo ''; diff --git a/db.php b/db.php index fe9b061..a2ad2aa 100644 --- a/db.php +++ b/db.php @@ -1,21 +1,31 @@ ' . "mysql:dbname=" . DB_NAME . ";host=" . DB_HOST . "," . DB_USERNAME . ", [****]" . ''; - $db = new PDO("mysql:dbname=" . DB_NAME . ";host=" . DB_HOST, DB_USERNAME, DB_PASSWORD); + if (DEBUG) echo '
Reusing DB connection.
'; } - catch (PDOException $e) + else { - echo '
Error connecting to database.
'; - dbError($e); - $db = null; //Redundant. + try + { + if (DEBUG) echo '
Connecting to DB: ' . "mysql:dbname=" . DB_NAME . ";host=" . DB_HOST . "," . DB_USERNAME . ", [****]" . '
'; + $db = new PDO("mysql:dbname=" . DB_NAME . ";host=" . DB_HOST, DB_USERNAME, DB_PASSWORD); + //Persistent connection: + //$db = new PDO("mysql:dbname=" . DB_NAME . ";host=" . DB_HOST, DB_USERNAME, DB_PASSWORD, array(PDO::ATTR_PERSISTENT => true); + } + catch (PDOException $e) + { + echo '
Error connecting to database.
'; + dbError($e); + $db = null; //Redundant. + } } return $db; @@ -289,7 +299,7 @@ function getMSQ($id) //TODO Rename? //TODO Pagination -function getAll() +function browseAll() { $db = connect(); if ($db == null) return null;