issue 173 - php4 parse error

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9243 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-09-20 12:31:50 +00:00
parent 0cc9b2e470
commit de8301ccbc
6 changed files with 57 additions and 1287 deletions

View file

@ -598,7 +598,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;
@ -611,7 +612,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()));
@ -624,11 +626,11 @@
$count_output = $this->_fetch($result);
$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

File diff suppressed because it is too large Load diff

View file

@ -716,19 +716,21 @@
}
function queryError($queryObject) {
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) {
$buff = new Object ();
$buff->total_count = 0;
$buff->total_page = 0;
$buff->page = 1;
$buff->data = array();
$buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values
}else
return;
}
$limit = $queryObject->getLimit();
if ($limit && $limit->isPageHandler()) {
$buff = new Object ();
$buff->total_count = 0;
$buff->total_page = 0;
$buff->page = 1;
$buff->data = array();
$buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values
}else
return;
}
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() != '') {
@ -740,11 +742,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
if ($total_count) $total_page = (int) (($total_count - 1) / $list_count) + 1;
@ -789,11 +791,11 @@
}
function getSelectSql($query, $with_values = true, $start_count = 0) {
if ($query->getLimit() && $query->getLimit()->isPageHandler()) {
$list_count = $query->getLimit()->list_count->getValue();
if(!$query->getLimit()->page) $page = 1;
else $page = $query->getLimit()->page->getValue();
$limit = $query->getLimit();
if ($limit && $limit->isPageHandler()) {
$list_count = $limit->list_count->getValue();
if(!$limit->page) $page = 1;
else $page = $limit->page->getValue();
if(!$start_count)
$start_count = ($page - 1) * $list_count;
$limit = sprintf('SELECT FIRST %d SKIP %d ', $list_count, $start_count);
@ -804,7 +806,7 @@
if ($select == '')
return new Object(-1, "Invalid query");
if ($query->getLimit() && $query->getLimit()->isPageHandler())
if ($limit && $limit->isPageHandler())
$select = $limit . ' ' . $select;
else
$select = 'SELECT ' . $select;

View file

@ -419,8 +419,9 @@
//if($limitOffset)
// TODO Implement Limit with offset with subquery
$limit = '';$limitCount = '';
if($query->getLimit())
$limitCount = $query->getLimit()->getLimit();
$limitQueryPart = $query->getLimit();
if($limitQueryPart)
$limitCount = $limitQueryPart->getLimit();
if($limitCount != '') $limit = 'SELECT TOP ' . $limitCount;
$select = $query->getSelectString($with_values);
@ -474,7 +475,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;
@ -487,7 +489,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() != '') {
@ -499,11 +502,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
if ($total_count) {

View file

@ -518,7 +518,8 @@ class DBPostgresql extends DB
if($orderBy != '') $orderBy = ' ORDER BY ' . $orderBy;
$limit = $query->getLimitString();
if($limit != '') $limit = ' LIMIT ' . $query->getLimit()->getLimit() . ' OFFSET ' . $query->getLimit()->getOffset();
$limitObject = $query->getLimit();
if($limit != '') $limit = ' LIMIT ' . $limitObject->getLimit() . ' OFFSET ' . $limitObject->getOffset();
return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
}
@ -554,7 +555,8 @@ class DBPostgresql extends DB
return;
}
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() != '') {
@ -568,19 +570,19 @@ class DBPostgresql extends DB
// Total pages
if ($total_count) {
$total_page = (int) (($total_count - 1) / $queryObject->getLimit()->list_count) + 1;
$total_page = (int) (($total_count - 1) / $limit->list_count) + 1;
} else $total_page = 1;
$virtual_no = $total_count - ($queryObject->getLimit()->page - 1) * $queryObject->getLimit()->list_count;
$virtual_no = $total_count - ($limit->page - 1) * $limit->list_count;
$data = $this->_fetch($result, $virtual_no);
$buff = new Object ();
$buff->total_count = $total_count;
$buff->total_page = $total_page;
$buff->page = $queryObject->getLimit()->page->getValue();
$buff->page = $limit->page->getValue();
$buff->data = $data;
$buff->page_navigation = new PageHandler($total_count, $total_page, $queryObject->getLimit()->page->getValue(), $queryObject->getLimit()->page_count);
$buff->page_navigation = new PageHandler($total_count, $total_page, $limit->page->getValue(), $limit->page_count);
}else{
$data = $this->_fetch($result);
$buff = new Object ();

View file

@ -81,19 +81,19 @@
if(!$this->database) return;
// Attempt to access the database file
try {
// PDO is only supported with PHP5,
// so it is allowed to use try~catch statment in this class.
$this->handler = new PDO('sqlite:'.$this->database);
} catch (PDOException $e) {
$this->setError(-1, 'Connection failed: '.$e->getMessage());
$this->is_connected = false;
return;
}
try {
// PDO is only supported with PHP5,
// so it is allowed to use try~catch statment in this class.
$this->handler = new PDO('sqlite:'.$this->database);
} catch (PDOException $e) {
$this->setError(-1, 'Connection failed: '.$e->getMessage());
$this->is_connected = false;
return;
}
// Check connections
$this->is_connected = true;
$this->password = md5($this->password);
$this->password = md5($this->password);
}
/**