Bug fix for compatibility of db classes with php 4.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9167 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-09-15 16:07:25 +00:00
parent 36190f9521
commit cb8e8cbccb
4 changed files with 17 additions and 13 deletions

View file

@ -232,7 +232,7 @@ class Context {
$slave_db = $db_info->master_db;
$db_info->slave_db = array($slave_db);
$self->setDBInfo($db_info);
$oInstallController = &getController('install');

View file

@ -37,7 +37,7 @@
* @brief constructor
**/
function DBMysql() {
$this->_setDBInfo();
$this->_setDBInfo();
$this->_connect();
}
@ -79,10 +79,8 @@
$this->setError(mysql_errno(), mysql_error());
return;
}
return $result;
// Set utf8 if a database is MySQL
$this->_query("set names 'utf8'");
}
function _afterConnect($connection){
@ -442,7 +440,8 @@
}
function queryError($queryObject){
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()){
$limit = $queryObject->getLimit();
if ($limit && $limit->isPageHandler()){
$buff = new Object ();
$buff->total_count = 0;
$buff->total_page = 0;
@ -455,7 +454,8 @@
}
function queryPageLimit($queryObject, $result, $connection){
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) {
$limit = $queryObject->getLimit();
if ($limit && $limit->isPageHandler()) {
// Total count
$count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($queryObject->getWhereString() === '' ? '' : ' WHERE '. $queryObject->getWhereString()));
if ($queryObject->getGroupByString() != '') {
@ -467,11 +467,11 @@
$count_output = $this->_fetch($result_count);
$total_count = (int)$count_output->count;
$list_count = $queryObject->getLimit()->list_count->getValue();
$list_count = $limit->list_count->getValue();
if (!$list_count) $list_count = 20;
$page_count = $queryObject->getLimit()->page_count->getValue();
$page_count = $limit->page_count->getValue();
if (!$page_count) $page_count = 10;
$page = $queryObject->getLimit()->page->getValue();
$page = $limit->page->getValue();
if (!$page) $page = 1;
// total pages

View file

@ -8,7 +8,9 @@
function Limit($list_count, $page= NULL, $page_count= NULL){
$this->list_count = $list_count;
if ($page){
$this->start = ($page-1)*$list_count->getValue();
$list_count_value = $list_count->getValue();
$page_value = $page->getValue();
$this->start = ($page_value - 1) * $list_count_value;
$this->page_count = $page_count;
$this->page = $page;
}

View file

@ -61,13 +61,15 @@
function parseExpression($column_name){
$functions = preg_split('/([\+\-\*\/\ ])/', $column_name, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
foreach($functions as &$function){
foreach($functions as $k => $v){
$function = &$functions[$k];
if(strlen($function)==1) continue; // skip delimiters
$pos = strrpos("(", $function);
$matches = preg_split('/([a-zA-Z0-9_*]+)/', $function, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
$total_brackets = substr_count($function, "(");
$brackets = 0;
foreach($matches as &$match){
foreach($matches as $i => $j){
$match = &$matches[$i];
if($match == '(') {$brackets++; continue;}
if(strpos($match,')') !== false) continue;
if(in_array($match, array(',', '.'))) continue;