Connect to DB before getting attribute

Attempt to fix the "PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute'" thrown on PHP 5.4. It could be that issuing PDO::getAttribute() before being connected to the DB prevents exception from being caught
This commit is contained in:
ozh 2017-09-03 21:53:03 +02:00
parent 8534e7d250
commit c0c91a02d2
2 changed files with 3 additions and 2 deletions

View File

@ -78,6 +78,8 @@ class YDB extends ExtendedPdo {
public function __construct($dsn, $user, $pass, $options, $attributes) {
parent::__construct($dsn, $user, $pass, $options, $attributes);
$this->connect_to_DB();
// Log query infos
$this->start_profiler();
}

View File

@ -53,8 +53,7 @@ function yourls_db_connect() {
$attributes = yourls_apply_filter( 'db_connect_attributes', array() ); // attributes as key-value pairs
$ydb = new \YOURLS\Database\YDB( $dsn, $user, $pass, $driver_options, $attributes );
yourls_debug_log(sprintf('Connecting to database %s on %s ', $dbname, $dbhost));
$ydb->connect_to_DB();
yourls_debug_log(sprintf('Connected to database %s on %s ', $dbname, $dbhost));
yourls_debug_mode(YOURLS_DEBUG);