Updating the db connection. master
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 12 Oct 2016 12:43:10 +0000 (08:43 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 12 Oct 2016 12:43:10 +0000 (08:43 -0400)
Option if the site doesn't have the class that we would use for PDO.
This will create it's own PDO connection to the database.

index.php

index a1ecb80..8a6730e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -8,7 +8,14 @@ $smarty->setCompileDir('./tmp_c/');
 $smarty->setConfigDir('./configs/');
 $smarty->setCacheDir('./cache/');
 
-$dbh = Toolkit_Database::getInstance();
+if ( class_exists( Toolkit_Database ) ) {
+    $dbh = Toolkit_Database::getInstance();
+} else {
+    $dsn = 'pgsql:' . CONN_STR;
+    $driverOptions = array( PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_BOTH );
+    $dbh = new PDO($dsn, null, null, $driverOptions);
+    $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
+}
 
 $sql = "
 SELECT *