Skip to content

Commit

Permalink
Merge pull request #2661 from pifou25/fix/bdd_notices
Browse files Browse the repository at this point in the history
fix: set pdo err mode silent
  • Loading branch information
zoic21 authored Jun 4, 2024
2 parents b773cdd + 7bee232 commit d56eb2c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions core/class/DB.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,19 @@ class DB {

private static function initConnection() {
global $CONFIG;
$_options = [
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci',
PDO::ATTR_PERSISTENT => true,
// silent mode, default for php7: https://www.php.net/manual/fr/pdo.error-handling.php
// exception mode for debug
PDO::ATTR_ERRMODE => (DEBUG ? PDO::ERRMODE_EXCEPTION : PDO::ERRMODE_SILENT),
];
if (isset($CONFIG['db']['unix_socket'])) {
static::$connection = new PDO('mysql:unix_socket=' . $CONFIG['db']['unix_socket'] . ';dbname=' . $CONFIG['db']['dbname'], $CONFIG['db']['username'], $CONFIG['db']['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci', PDO::ATTR_PERSISTENT => true));
static::$connection = new PDO('mysql:unix_socket=' . $CONFIG['db']['unix_socket'] . ';dbname=' . $CONFIG['db']['dbname'],
$CONFIG['db']['username'], $CONFIG['db']['password'], $_options);
} else {
static::$connection = new PDO('mysql:host=' . $CONFIG['db']['host'] . ';port=' . $CONFIG['db']['port'] . ';dbname=' . $CONFIG['db']['dbname'], $CONFIG['db']['username'], $CONFIG['db']['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci', PDO::ATTR_PERSISTENT => true));
static::$connection = new PDO('mysql:host=' . $CONFIG['db']['host'] . ';port=' . $CONFIG['db']['port'] . ';dbname=' . $CONFIG['db']['dbname'],
$CONFIG['db']['username'], $CONFIG['db']['password'], $_options);
}
}

Expand Down

0 comments on commit d56eb2c

Please sign in to comment.