Issue 1851: Fix PHP Warnings and notices in DB Classes

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10537 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2012-04-06 09:47:45 +00:00
parent 23e508e1b8
commit 1bc92129b0
31 changed files with 164 additions and 89 deletions

View file

@ -214,9 +214,8 @@
* @param[in] $db_type type of db to check
* @return true: is supported, false: is not supported
**/
function isSupported($db_type) {
$supported_list = DB::getSupportedList();
return in_array($db_type, $supported_list);
function isSupported() {
return FALSE;
}
/**
@ -634,7 +633,7 @@
}
function _getConnection($type = 'master', $indx = NULL){
if($type == master){
if($type == 'master'){
if(!$this->master_db['is_connected'])
$this->_connect($type);
$this->connection = 'Master ' . $this->master_db['db_hostname'];
@ -767,7 +766,7 @@
$this->use_prepared_statements = $db_info->use_prepared_statements;
}
function __connect(){
function __connect($connection){
}

View file

@ -525,6 +525,10 @@
$query = sprintf ("alter class \"%s\" add attribute ", $table_name);
$primary_list = array();
$unique_list = array();
$index_list = array();
foreach ($columns as $column) {
$name = $column->attrs->name;
$type = $column->attrs->type;
@ -723,7 +727,7 @@
$count_query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
$result = $this->_query($count_query, $connection);
$count_output = $this->_fetch($result);
$total_count = (int)$count_output->count;
$total_count = (int)(isset($count_output->output) ? $count_output->count : NULL);
$list_count = $limit->list_count->getValue();
if (!$list_count) $list_count = 20;
@ -773,8 +777,9 @@
return $buff;
}
function getParser(){
return new DBParser('"', '"', $this->prefix);
function &getParser($force = FALSE){
$dbParser = new DBParser('"', '"', $this->prefix);
return $dbParser;
}
function getSelectPageSql($query, $with_values = true, $start_count = 0, $list_count = 0) {

View file

@ -377,6 +377,10 @@
if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column;
else $columns = $xml_obj->table->column;
$primary_list = array();
$unique_list = array();
$index_list = array();
foreach($columns as $column) {
$name = $column->attrs->name;
$type = $column->attrs->type;
@ -459,7 +463,7 @@
$alias_list = '';
foreach($tables as $table)
$alias_list .= $table->getAlias();
join(',', split(' ', $alias_list));
implode(',', explode(' ', $alias_list));
$where = $query->getWhereString($with_values);
if($where != '') $where = ' WHERE ' . $where;
@ -478,7 +482,7 @@
return $this->_query($query);
}
function getSelectSql($query){
function getSelectSql($query, $with_values = TRUE){
$with_values = false;
//$limitOffset = $query->getLimit()->getOffset();
@ -536,8 +540,9 @@
else return $this->queryPageLimit($queryObject, $result, $connection);
}
function getParser(){
return new DBParser("[", "]", $this->prefix);
function &getParser($force = FALSE){
$dbParser = new DBParser("[", "]", $this->prefix);
return $dbParser;
}
function queryError($queryObject){
@ -597,11 +602,10 @@
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
return $buff;
}
$start_count = ($page - 1) * $list_count;
$query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$this->param = $queryObject->getArguments();
$virtual_no = $total_count - ($page - 1) * $list_count;
$virtual_no = $total_count - $start_count;
$data = $this->_fetch($result, $virtual_no);
$buff = new Object ();

View file

@ -317,6 +317,10 @@
if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column;
else $columns = $xml_obj->table->column;
$primary_list = array();
$unique_list = array();
$index_list = array();
foreach($columns as $column) {
$name = $column->attrs->name;
$type = $column->attrs->type;
@ -399,6 +403,7 @@
**/
function _executeSelectAct($queryObject, $connection = null, $with_values = true) {
$limit = $queryObject->getLimit();
$result = NULL;
if ($limit && $limit->isPageHandler())
return $this->queryPageLimit($queryObject, $result, $connection, $with_values);
else {
@ -433,8 +438,9 @@
return mysql_free_result($result);
}
function getParser(){
return new DBParser('`', '`', $this->prefix);
function &getParser($force = FALSE){
$dbParser = new DBParser('`', '`', $this->prefix);
return $dbParser;
}
function queryError($queryObject){
@ -459,6 +465,7 @@
// Check for distinct query and if found update count query structure
$temp_select = $queryObject->getSelectString($with_values);
$uses_distinct = false;
if(strpos(strtolower($temp_select), "distinct") !== false) {
$count_query = sprintf('select %s %s %s', 'FROM ' . $queryObject->getFromString($with_values), $temp_select, ($temp_where === '' ? '' : ' WHERE '. $temp_where));
$uses_distinct = true;
@ -472,7 +479,7 @@
$count_query .= (__DEBUG_QUERY__&1 && $queryObject->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
$result_count = $this->_query($count_query, $connection);
$count_output = $this->_fetch($result_count);
$total_count = (int)$count_output->count;
$total_count = (int)(isset($count_output->count) ? $count_output->count : NULL);
$list_count = $limit->list_count->getValue();
if (!$list_count) $list_count = 20;

View file

@ -247,46 +247,46 @@
return $output;
}
function _executeInsertAct($queryObject){
function _executeInsertAct($queryObject, $with_values = false){
if($this->use_prepared_statements != 'Y')
{
return parent::_executeInsertAct($queryObject);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeInsertAct($queryObject, false);
$result = parent::_executeInsertAct($queryObject, $with_values);
unset($this->param);
return $result;
}
function _executeUpdateAct($queryObject) {
function _executeUpdateAct($queryObject, $with_values = false) {
if($this->use_prepared_statements != 'Y')
{
return parent::_executeUpdateAct($queryObject);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeUpdateAct($queryObject, false);
$result = parent::_executeUpdateAct($queryObject, $with_values);
unset($this->param);
return $result;
}
function _executeDeleteAct($queryObject) {
function _executeDeleteAct($queryObject, $with_values = false) {
if($this->use_prepared_statements != 'Y')
{
return parent::_executeDeleteAct($queryObject);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeDeleteAct($queryObject, false);
$result = parent::_executeDeleteAct($queryObject, $with_values);
unset($this->param);
return $result;
}
function _executeSelectAct($queryObject, $connection = null) {
function _executeSelectAct($queryObject, $connection = null, $with_values = false) {
if($this->use_prepared_statements != 'Y')
{
return parent::_executeSelectAct($queryObject, $connection);
}
$this->param = $queryObject->getArguments();
$result = parent::_executeSelectAct($queryObject, $connection, false);
$result = parent::_executeSelectAct($queryObject, $connection, $with_values);
unset($this->param);
return $result;
}

View file

@ -25,7 +25,8 @@
, $conditions = null
, $groups = null
, $orderby = null
, $limit = null){
, $limit = null
, $priority = null){
$this->queryID = $queryID;
$this->action = $action;
$this->priority = $priority;
@ -313,8 +314,8 @@
if(count($this->columns) > 0){ // The if is for delete statements, all others must have columns
foreach($this->columns as $column){
if($column->show()){
$arg = $column->getArgument();
if($arg) $this->arguments[] = $arg;
$args = $column->getArguments();
if($args) $this->arguments = array_merge($this->arguments, $args);
}
}
}
@ -339,4 +340,4 @@
?>
?>

View file

@ -30,6 +30,7 @@
function toString($with_values = true){
$oDB = &DB::getInstance();
return '(' .$oDB->getSelectSql($this, $with_values) . ')';
}
@ -38,5 +39,3 @@
return true;
}
}
?>

View file

@ -31,6 +31,14 @@
function getArgument(){
return $this->argument;
}
function getArguments()
{
if ($this->argument)
return array($this->argument);
else
return array();
}
}
?>
?>

View file

@ -33,8 +33,13 @@
return null;
}
function getArguments()
{
return array();
}
function isSubquery(){
return false;
}
}
?>
?>

View file

@ -16,5 +16,10 @@
function getArgument(){
return null;
}
function getArguments(){
// StarExpression has no arguments
return array();
}
}
?>
?>

View file

@ -52,7 +52,15 @@
function getArgument(){
return $this->argument;
}
function getArguments()
{
if ($this->argument)
return array($this->argument);
else
return array();
}
}
?>
?>