* add two config items of database.

This commit is contained in:
wangchunsheng
2011-09-07 08:05:13 +00:00
parent e623b6ba9f
commit a2e0a16981
2 changed files with 11 additions and 11 deletions

View File

@@ -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;

View File

@@ -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)