changer la configuration par défaut pour mysql

This commit is contained in:
Jephté Clain 2025-10-06 08:04:16 +04:00
parent ff4ef34037
commit 526a693ead
2 changed files with 12 additions and 1 deletions

View File

@ -6,11 +6,22 @@ use nulib\db\pdo\Pdo;
class Mysql extends Pdo {
const PREFIX = "mysql";
static function config_setTimeout(self $pdo): void {
$pdo->_exec("SET session wait_timeout=28800");
$pdo->_exec("SET session interactive_timeout=28800");
}
const CONFIG_setTimeout = [self::class, "config_setTimeout"];
static function config_unbufferedQueries(self $mysql): void {
$mysql->db->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
}
const CONFIG_unbufferedQueries = [self::class, "config_unbufferedQueries"];
const DEFAULT_CONFIG = [
...parent::DEFAULT_CONFIG,
self::CONFIG_setTimeout,
];
function getDbname(): ?string {
$url = $this->dbconn["name"] ?? null;
if ($url !== null && preg_match('/^mysql(?::|.*;)dbname=([^;]+)/i', $url, $ms)) {

View File

@ -42,7 +42,7 @@ class Pdo implements IDatabase {
const CONFIG_errmodeException_lowerCase = [self::class, "config_errmodeException_lowerCase"];
protected const OPTIONS = [
\PDO::ATTR_PERSISTENT => true,
\PDO::ATTR_PERSISTENT => false,
];
protected const DEFAULT_CONFIG = [