Database connection error

' . $exception->getMessage() . '

'); } // PDO constructor is public so we can't make this private and uninstantiable public function __construct($dsn, $username='', $password='', $driver_options=array()) { // Temporarily change the PHP exception handler while we . . . set_exception_handler(array(__CLASS__, 'exception_handler')); // Find out who tried to call the constructor $chain = debug_backtrace(); $caller = $chain[1]['class']; // Enforce SprocketPDO_Factory creation if ('SprocketPDO_Factory' == $caller) { // . . . create a PDO object parent::__construct($dsn, $username, $password, $driver_options); } else { throw new Exception('Cannot directly instantiate. Please use SprocketPDO_Factory'); } // Make the options available $this->options = $driver_options; // Define the PDO Statement class $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('extendedPDOStatement', array($this))); // Change the exception handler back to whatever it was before restore_exception_handler(); } public function prepare($sql) { $tokens = array(); // Check if the option is enabled if (true === $this->options['singleTokenMultiParams']) { // Parse the SQL query for placeholders preg_match_all("/(\:\w+)/", $sql, $matches, PREG_PATTERN_ORDER); foreach($matches[1] as $index=>$token) { $tokens[$token]++; } // For each placeholder foreach($tokens as $token=>$count) { // Check if the placeholder is repeated if ($count > 1) { // Find where to start searching (after the first occurrence) $start = strpos($sql, $token); $length = strlen($token); // Replace each additional occurrence with a unique placeholder do { $start = strpos($sql, $token, $start+1); if (false !== $start) { $loop++; $sql = substr_replace($sql, $token . '_' . $loop, $start, $length); } } while(false !== $start); } } } // Call the standard prepare method $pdoStatement = parent::prepare($sql); // Store the tokens used with this query $this->tokens[$pdoStatement->queryString] = $tokens; return $pdoStatement; } } ?>