From d42eecad3d9f2c4b936387a045877753ec28d5c5 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Mon, 20 May 2013 03:58:17 +0200 Subject: [PATCH] Swap the class and procedural code in the PDO include, to avoid breakage --- include.mysql.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/include.mysql.php b/include.mysql.php index a8d0316..683a73f 100644 --- a/include.mysql.php +++ b/include.mysql.php @@ -15,25 +15,6 @@ if($_CPHP !== true) { die(); } $cphp_mysql_connected = false; -if(!empty($cphp_config->database->driver)) -{ - if(empty($cphp_config->database->database)) - { - die("No database was configured. Refer to the CPHP manual for instructions."); - } - - try - { - $database = new CachedPDO("mysql:host={$cphp_config->database->hostname};dbname={$cphp_config->database->database}", $cphp_config->database->username, $cphp_config->database->password); - $database->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_TO_STRING); - $cphp_mysql_connected = true; - } - catch (Exception $e) - { - die("Could not connect to the specified database. Refer to the CPHP manual for instructions."); - } -} - class CachedPDO extends PDO { public function CachedQuery($query, $parameters = array(), $expiry = 60) @@ -136,3 +117,22 @@ class CachedPDO extends PDO } } } + +if(!empty($cphp_config->database->driver)) +{ + if(empty($cphp_config->database->database)) + { + die("No database was configured. Refer to the CPHP manual for instructions."); + } + + try + { + $database = new CachedPDO("mysql:host={$cphp_config->database->hostname};dbname={$cphp_config->database->database}", $cphp_config->database->username, $cphp_config->database->password); + $database->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_TO_STRING); + $cphp_mysql_connected = true; + } + catch (Exception $e) + { + die("Could not connect to the specified database. Refer to the CPHP manual for instructions."); + } +}