Swap the class and procedural code in the PDO include, to avoid breakage

develop
Sven Slootweg 11 years ago
parent 539f54eac1
commit d42eecad3d

@ -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.");
}
}

Loading…
Cancel
Save