Fix - read table prefix from db_config file instead of always using default "xe_".

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8700 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-07-29 07:51:15 +00:00
parent 4ead81754f
commit abf5a1f5a3
5 changed files with 70 additions and 70 deletions

View file

@ -685,7 +685,7 @@
} }
function getParser(){ function getParser(){
return new DBParser('"'); return new DBParser('"', '"', $this->prefix);
} }
} }

View file

@ -45,7 +45,7 @@
$this->_setDBInfo(); $this->_setDBInfo();
$this->_connect(); $this->_connect();
} }
/** /**
* @brief create an instance of this class * @brief create an instance of this class
*/ */
@ -601,7 +601,7 @@
// auto_increment in Firebird creates a generator which activates a trigger when insert occurs // auto_increment in Firebird creates a generator which activates a trigger when insert occurs
// the generator increases the value of the generator and then insert to the table // the generator increases the value of the generator and then insert to the table
// The trigger below acts like auto_increment however I commented the below because the trigger cannot be defined by a query statement // The trigger below acts like auto_increment however I commented the below because the trigger cannot be defined by a query statement
// php api has a function to increase a generator, so // php api has a function to increase a generator, so
// no need to use auto increment in XE // no need to use auto increment in XE
/* /*
$schema = 'SET TERM ^ ; '; $schema = 'SET TERM ^ ; ';
@ -640,7 +640,7 @@
* @brief handles deleteAct * @brief handles deleteAct
**/ **/
function _executeDeleteAct($queryObject) { function _executeDeleteAct($queryObject) {
$query = $this->getDeleteSql($queryObject); $query = $this->getDeleteSql($queryObject);
if(is_a($query, 'Object')) return; if(is_a($query, 'Object')) return;
return $this->_query($query); return $this->_query($query);
} }
@ -653,15 +653,15 @@
**/ **/
function _executeSelectAct($queryObject) { function _executeSelectAct($queryObject) {
$query = $this->getSelectSql($queryObject); $query = $this->getSelectSql($queryObject);
if(is_a($query, 'Object')) return; if(is_a($query, 'Object')) return;
$query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):''; $query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
$result = $this->_query ($query); $result = $this->_query ($query);
if ($this->isError ()) return $this->queryError($queryObject); if ($this->isError ()) return $this->queryError($queryObject);
else return $this->queryPageLimit($queryObject, $result); else return $this->queryPageLimit($queryObject, $result);
} }
function queryError($queryObject) { function queryError($queryObject) {
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) { if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) {
$buff = new Object (); $buff = new Object ();
@ -696,7 +696,7 @@
$virtual_no = $total_count - ($queryObject->getLimit()->page - 1) * $queryObject->getLimit()->list_count; $virtual_no = $total_count - ($queryObject->getLimit()->page - 1) * $queryObject->getLimit()->list_count;
while ($tmp = ibase_fetch_object($result)) while ($tmp = ibase_fetch_object($result))
$data[$virtual_no--] = $tmp; $data[$virtual_no--] = $tmp;
if (!$this->transaction_started) if (!$this->transaction_started)
@ibase_commit($this->fd); @ibase_commit($this->fd);
@ -715,7 +715,7 @@
} }
function getParser() { function getParser() {
return new DBParser('"'); return new DBParser('"', '"', $this->prefix);
} }
function getSelectSql($query, $with_values = true) { function getSelectSql($query, $with_values = true) {

View file

@ -515,7 +515,7 @@
} }
function getParser(){ function getParser(){
return new DBParser("[", "]"); return new DBParser("[", "]", $this->prefix);
} }
function queryError($queryObject){ function queryError($queryObject){

View file

@ -44,7 +44,7 @@
$this->_setDBInfo(); $this->_setDBInfo();
$this->_connect(); $this->_connect();
} }
function create() { function create() {
return new DBMysql; return new DBMysql;
} }
@ -171,7 +171,7 @@
else $output[] = $tmp; else $output[] = $tmp;
} }
if(count($output)==1){ if(count($output)==1){
if(isset($arrayIndexEndValue)) return $output; if(isset($arrayIndexEndValue)) return $output;
else return $output[0]; else return $output[0];
} }
return $output; return $output;
@ -411,9 +411,9 @@
**/ **/
function _executeDeleteAct($queryObject) { function _executeDeleteAct($queryObject) {
$query = $this->getDeleteSql($queryObject); $query = $this->getDeleteSql($queryObject);
if(is_a($query, 'Object')) return; if(is_a($query, 'Object')) return;
//priority setting //priority setting
// TODO Check what priority does // TODO Check what priority does
//$priority = ''; //$priority = '';
@ -429,17 +429,17 @@
**/ **/
function _executeSelectAct($queryObject) { function _executeSelectAct($queryObject) {
$query = $this->getSelectSql($queryObject); $query = $this->getSelectSql($queryObject);
if(is_a($query, 'Object')) return; if(is_a($query, 'Object')) return;
$query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):''; $query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
// TODO Add support for click count // TODO Add support for click count
// TODO Add code for pagination // TODO Add code for pagination
$result = $this->_query ($query); $result = $this->_query ($query);
if ($this->isError ()) return $this->queryError($queryObject); if ($this->isError ()) return $this->queryError($queryObject);
else return $this->queryPageLimit($queryObject, $result); else return $this->queryPageLimit($queryObject, $result);
} }
function db_insert_id() function db_insert_id()
@ -451,11 +451,11 @@
{ {
return mysql_fetch_object($result); return mysql_fetch_object($result);
} }
function getParser(){ function getParser(){
return new DBParser('`'); return new DBParser('`', '`', $this->prefix);
} }
function queryError($queryObject){ function queryError($queryObject){
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()){ if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()){
$buff = new Object (); $buff = new Object ();
@ -465,10 +465,10 @@
$buff->data = array (); $buff->data = array ();
$buff->page_navigation = new PageHandler (/*$total_count*/0, /*$total_page*/1, /*$page*/1, /*$page_count*/10);//default page handler values $buff->page_navigation = new PageHandler (/*$total_count*/0, /*$total_page*/1, /*$page*/1, /*$page_count*/10);//default page handler values
return $buff; return $buff;
}else }else
return; return;
} }
function queryPageLimit($queryObject, $result){ function queryPageLimit($queryObject, $result){
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) { if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) {
// Total count // Total count
@ -481,12 +481,12 @@
$result_count = $this->_query($count_query); $result_count = $this->_query($count_query);
$count_output = $this->_fetch($result_count); $count_output = $this->_fetch($result_count);
$total_count = (int)$count_output->count; $total_count = (int)$count_output->count;
// Total pages // Total pages
if ($total_count) { if ($total_count) {
$total_page = (int) (($total_count - 1) / $queryObject->getLimit()->list_count) + 1; $total_page = (int) (($total_count - 1) / $queryObject->getLimit()->list_count) + 1;
} else $total_page = 1; } else $total_page = 1;
$virtual_no = $total_count - ($queryObject->getLimit()->page - 1) * $queryObject->getLimit()->list_count; $virtual_no = $total_count - ($queryObject->getLimit()->page - 1) * $queryObject->getLimit()->list_count;
$data = $this->_fetch($result, $virtual_no); $data = $this->_fetch($result, $virtual_no);
@ -495,11 +495,11 @@
$buff->total_page = $total_page; $buff->total_page = $total_page;
$buff->page = $queryObject->getLimit()->page->getValue(); $buff->page = $queryObject->getLimit()->page->getValue();
$buff->data = $data; $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, $queryObject->getLimit()->page->getValue(), $queryObject->getLimit()->page_count);
}else{ }else{
$data = $this->_fetch($result); $data = $this->_fetch($result);
$buff = new Object (); $buff = new Object ();
$buff->data = $data; $buff->data = $data;
} }
return $buff; return $buff;
} }

View file

@ -26,19 +26,19 @@ class DBPostgresql extends DB
var $comment_syntax = '/* %s */'; var $comment_syntax = '/* %s */';
/** /**
* @brief column type used in postgresql * @brief column type used in postgresql
* *
* Becasue a common column type in schema/query xml is used for colum_type, * Becasue a common column type in schema/query xml is used for colum_type,
* it should be replaced properly for each DBMS * it should be replaced properly for each DBMS
**/ **/
var $column_type = array( var $column_type = array(
'bignumber' => 'bigint', 'bignumber' => 'bigint',
'number' => 'integer', 'number' => 'integer',
'varchar' => 'varchar', 'varchar' => 'varchar',
'char' => 'char', 'char' => 'char',
'text' => 'text', 'text' => 'text',
'bigtext' => 'text', 'bigtext' => 'text',
'date' => 'varchar(14)', 'date' => 'varchar(14)',
'float' => 'real', 'float' => 'real',
); );
@ -50,7 +50,7 @@ class DBPostgresql extends DB
$this->_setDBInfo(); $this->_setDBInfo();
$this->_connect(); $this->_connect();
} }
/** /**
* @brief create an instance of this class * @brief create an instance of this class
*/ */
@ -194,12 +194,12 @@ class DBPostgresql extends DB
$query = implode(" ",$l_query_array); $query = implode(" ",$l_query_array);
} }
} }
else if ($l_query_array[0] = "delete") else if ($l_query_array[0] = "delete")
{ {
if (strtolower($l_query_array[3]) == "as") if (strtolower($l_query_array[3]) == "as")
{ {
$l_query_array[3] = ""; $l_query_array[3] = "";
$l_query_array[4] = ""; $l_query_array[4] = "";
$query = implode(" ",$l_query_array); $query = implode(" ",$l_query_array);
} }
} }
@ -233,12 +233,12 @@ class DBPostgresql extends DB
return; return;
while ($tmp = pg_fetch_object($result)) { while ($tmp = pg_fetch_object($result)) {
if($arrayIndexEndValue) $output[$arrayIndexEndValue--] = $tmp; if($arrayIndexEndValue) $output[$arrayIndexEndValue--] = $tmp;
else $output[] = $tmp; else $output[] = $tmp;
} }
if(count($output)==1){ if(count($output)==1){
if(isset($arrayIndexEndValue)) return $output; if(isset($arrayIndexEndValue)) return $output;
else return $output[0]; else return $output[0];
} }
return $output; return $output;
} }
@ -295,7 +295,7 @@ class DBPostgresql extends DB
} }
if ($notnull) { if ($notnull) {
$query = sprintf("update %s%s set %s = %s ", $this->prefix, $table_name, $column_name, $default); $query = sprintf("update %s%s set %s = %s ", $this->prefix, $table_name, $column_name, $default);
$this->_query($query); $this->_query($query);
$query = sprintf("alter table %s%s alter %s set not null ", $this->prefix, $table_name, $column_name); $query = sprintf("alter table %s%s alter %s set not null ", $this->prefix, $table_name, $column_name);
$this->_query($query); $this->_query($query);
} }
@ -497,7 +497,7 @@ class DBPostgresql extends DB
} }
/** /**
* @brief Handle the insertAct * @brief Handle the insertAct
**/ **/
@ -505,7 +505,7 @@ class DBPostgresql extends DB
{ {
$query = $this->getInsertSql($queryObject); $query = $this->getInsertSql($queryObject);
if(is_a($query, 'Object')) return; if(is_a($query, 'Object')) return;
return $this->_query($query); return $this->_query($query);
} }
@ -525,13 +525,13 @@ class DBPostgresql extends DB
function _executeDeleteAct($queryObject) function _executeDeleteAct($queryObject)
{ {
$query = $this->getDeleteSql($queryObject); $query = $this->getDeleteSql($queryObject);
if(is_a($query, 'Object')) return; if(is_a($query, 'Object')) return;
return $this->_query($query); return $this->_query($query);
} }
/** /**
* *
* override * override
* @param $queryObject * @param $queryObject
*/ */
@ -539,26 +539,26 @@ class DBPostgresql extends DB
$select = $query->getSelectString(); $select = $query->getSelectString();
if($select == '') return new Object(-1, "Invalid query"); if($select == '') return new Object(-1, "Invalid query");
$select = 'SELECT ' .$select; $select = 'SELECT ' .$select;
$from = $query->getFromString(); $from = $query->getFromString();
if($from == '') return new Object(-1, "Invalid query"); if($from == '') return new Object(-1, "Invalid query");
$from = ' FROM '.$from; $from = ' FROM '.$from;
$where = $query->getWhereString(); $where = $query->getWhereString();
if($where != '') $where = ' WHERE ' . $where; if($where != '') $where = ' WHERE ' . $where;
$groupBy = $query->getGroupByString(); $groupBy = $query->getGroupByString();
if($groupBy != '') $groupBy = ' GROUP BY ' . $groupBy; if($groupBy != '') $groupBy = ' GROUP BY ' . $groupBy;
$orderBy = $query->getOrderByString(); $orderBy = $query->getOrderByString();
if($orderBy != '') $orderBy = ' ORDER BY ' . $orderBy; if($orderBy != '') $orderBy = ' ORDER BY ' . $orderBy;
$limit = $query->getLimitString(); $limit = $query->getLimitString();
if($limit != '') $limit = ' LIMIT ' . $query->getLimit()->getLimit() . ' OFFSET ' . $query->getLimit()->getOffset(); if($limit != '') $limit = ' LIMIT ' . $query->getLimit()->getLimit() . ' OFFSET ' . $query->getLimit()->getOffset();
return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit; return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
} }
/** /**
* @brief Handle selectAct * @brief Handle selectAct
* *
@ -568,14 +568,14 @@ class DBPostgresql extends DB
function _executeSelectAct($queryObject) function _executeSelectAct($queryObject)
{ {
$query = $this->getSelectSql($queryObject); $query = $this->getSelectSql($queryObject);
if(is_a($query, 'Object')) return; if(is_a($query, 'Object')) return;
$query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):''; $query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
// TODO Add support for click count // TODO Add support for click count
// TODO Add code for pagination // TODO Add code for pagination
$result = $this->_query ($query); $result = $this->_query ($query);
if ($this->isError ()) { if ($this->isError ()) {
if ($limit && $output->limit->isPageHandler()){ if ($limit && $output->limit->isPageHandler()){
@ -586,7 +586,7 @@ class DBPostgresql extends DB
$buff->data = array (); $buff->data = array ();
$buff->page_navigation = new PageHandler (/*$total_count*/0, /*$total_page*/1, /*$page*/1, /*$page_count*/10);//default page handler values $buff->page_navigation = new PageHandler (/*$total_count*/0, /*$total_page*/1, /*$page*/1, /*$page_count*/10);//default page handler values
return $buff; return $buff;
}else }else
return; return;
} }
@ -601,13 +601,13 @@ class DBPostgresql extends DB
$result_count = $this->_query($count_query); $result_count = $this->_query($count_query);
$count_output = $this->_fetch($result_count); $count_output = $this->_fetch($result_count);
$total_count = (int)$count_output->count; $total_count = (int)$count_output->count;
// Total pages // Total pages
if ($total_count) { if ($total_count) {
$total_page = (int) (($total_count - 1) / $queryObject->getLimit()->list_count) + 1; $total_page = (int) (($total_count - 1) / $queryObject->getLimit()->list_count) + 1;
} else $total_page = 1; } else $total_page = 1;
$virtual_no = $total_count - ($queryObject->getLimit()->page - 1) * $queryObject->getLimit()->list_count; $virtual_no = $total_count - ($queryObject->getLimit()->page - 1) * $queryObject->getLimit()->list_count;
$data = $this->_fetch($result, $virtual_no); $data = $this->_fetch($result, $virtual_no);
@ -616,18 +616,18 @@ class DBPostgresql extends DB
$buff->total_page = $total_page; $buff->total_page = $total_page;
$buff->page = $queryObject->getLimit()->page->getValue(); $buff->page = $queryObject->getLimit()->page->getValue();
$buff->data = $data; $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, $queryObject->getLimit()->page->getValue(), $queryObject->getLimit()->page_count);
}else{ }else{
$data = $this->_fetch($result); $data = $this->_fetch($result);
$buff = new Object (); $buff = new Object ();
$buff->data = $data; $buff->data = $data;
} }
return $buff; return $buff;
} }
function getParser(){ function getParser(){
return new DBParser('"'); return new DBParser('"', '"', $this->prefix);
} }
} }