* move the isCentOS to helper.

This commit is contained in:
wangchunsheng
2011-03-08 09:14:13 +00:00
parent 3f1a13887c
commit 6f6cd0da75
2 changed files with 16 additions and 15 deletions
+15
View File
@@ -323,6 +323,21 @@ class helper
chdir($cwd);
}
}
/**
* Judge the os is centos or not.
*
* @access private
* @return bool
*/
static public function isCentOS()
{
if(PHP_OS != 'Linux') return false;
$issueFile = '/etc/issue';
if(!file_exists($issueFile) or !is_readable($issueFile)) return false;
return stripos(file_get_contents($issueFile), 'centos') !== false;
}
}
/**
+1 -15
View File
@@ -1464,7 +1464,7 @@ class router
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->exec("SET NAMES {$config->db->encoding}");
if(isset($config->db->strictMode) and $config->db->strictMode == false) $dbh->exec("SET @@sql_mode= ''");
if($this->isCentOS()) $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
if(helper::isCentOS()) $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$this->dbh = $dbh;
return $dbh;
}
@@ -1473,20 +1473,6 @@ class router
self::error($exception->getMessage(), __FILE__, __LINE__, $exit = true);
}
}
/**
* Judge the os is centos or not.
*
* @access private
* @return bool
*/
private function isCentOS()
{
if(PHP_OS != 'Linux') return false;
$issueFile = '/etc/issue';
if(!file_exists($issueFile) or !is_readable($issueFile)) return false;
return stripos(file_get_contents($issueFile), 'centos') !== false;
}
}
/**