diff --git a/config/config.php b/config/config.php index 878372324b..28f04b10ed 100644 --- a/config/config.php +++ b/config/config.php @@ -48,11 +48,12 @@ $config->file->dangers = 'php,jsp,py,rb,asp,'; // Dangerous files. $config->file->maxSize = 1024 * 1024; // Max size. /* Master database settings. */ -$config->db->persistant = false; // Pconnect or not. -$config->db->driver = 'mysql'; // Must be MySQL. Don't support other database server yet. -$config->db->encoding = 'UTF8'; // Encoding of database. -$config->db->strictMode = false; // Turn off the strict mode of MySQL. -$config->db->checkCentOS= true; // Whether check is centos or not, thus to fix the error of pdo in centos. +$config->db->persistant = false; // Pconnect or not. +$config->db->driver = 'mysql'; // Must be MySQL. Don't support other database server yet. +$config->db->encoding = 'UTF8'; // Encoding of database. +$config->db->strictMode = false; // Turn off the strict mode of MySQL. +//$config->db->emulatePrepare = true; // PDO::ATTR_EMULATE_PREPARES +//$config->db->bufferQuery = true; // PDO::MYSQL_ATTR_USE_BUFFERED_QUERY /* Slave database settings. */ $config->slaveDB->persistant = false; diff --git a/framework/router.class.php b/framework/router.class.php index c70befbfe3..d81b494e88 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -1488,15 +1488,14 @@ class router try { $dbh = new PDO($dsn, $params->user, $params->password, array(PDO::ATTR_PERSISTENT => $params->persistant)); + $dbh->exec("SET NAMES {$params->encoding}"); + $dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $dbh->exec("SET NAMES {$params->encoding}"); if(isset($params->strictMode) and $params->strictMode == false) $dbh->exec("SET @@sql_mode= ''"); - if(isset($params->checkCentOS) and $params->checkCentOS and helper::isCentOS()) - { - $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); - $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); - } + if(isset($params->emulatePrepare)) $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, $params->emulatePrepare); + if(isset($params->bufferQuery)) $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, $params->bufferQuery); + return $dbh; } catch (PDOException $exception)