diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php index f49e8710b..71dc76e34 100644 --- a/classes/db/DB.class.php +++ b/classes/db/DB.class.php @@ -319,13 +319,16 @@ require_once(_XE_PATH_.'classes/db/queryparts/expression/Expression.class.php'); require_once(_XE_PATH_.'classes/db/queryparts/expression/SelectExpression.class.php'); require_once(_XE_PATH_.'classes/db/queryparts/expression/InsertExpression.class.php'); + require_once(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpression.class.php'); require_once(_XE_PATH_.'classes/db/queryparts/table/Table.class.php'); require_once(_XE_PATH_.'classes/db/queryparts/table/JoinTable.class.php'); require_once(_XE_PATH_.'classes/db/queryparts/condition/ConditionGroup.class.php'); require_once(_XE_PATH_.'classes/db/queryparts/condition/Condition.class.php'); require_once(_XE_PATH_.'classes/db/queryparts/expression/StarExpression.class.php'); + require_once(_XE_PATH_.'classes/db/queryparts/order/OrderByColumn.class.php'); - $output = @include($cache_file); + + $output = include($cache_file); if( (is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output; $output->_tables = ($output->_tables && is_array($output->_tables)) ? $output->_tables : array(); diff --git a/classes/db/DBCubrid.class.php b/classes/db/DBCubrid.class.php index 10b96ca97..1df9d207e 100644 --- a/classes/db/DBCubrid.class.php +++ b/classes/db/DBCubrid.class.php @@ -669,20 +669,20 @@ $columnsList = substr($columnsList, 0, -2); $valuesList = substr($valuesList, 0, -2); - // TODO Make sure column values are escaped. Preferably directly from the cache file and not in here - $query = "INSERT INTO $tableName ($columnsList) VALUES ($valuesList)"; - - return $query; - /*$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):''; + $query = "INSERT INTO $tableName \n ($columnsList) \n VALUES ($valuesList)"; + + $query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):''; $result = $this->_query ($query); if ($result && !$this->transaction_started) { @cubrid_commit ($this->fd); } return $result; - */ - } + } + /** + * @brief handles updateAct + **/ function _executeUpdateAct ($output) { $query = ''; @@ -690,34 +690,35 @@ $tableName = $output->tables[0]->getName(); $columnsList = ''; - $valuesList = ''; foreach($output->columns as $column){ if($column->show()){ - $columnsList .= $column->getColumnName() . ', '; - $valuesList .= $column->getValue() . ', '; + $columnsList .= $column->getExpression() . ', '; } } $columnsList = substr($columnsList, 0, -2); - $valuesList = substr($valuesList, 0, -2); + + $where = ''; + if(count($output->conditions) > 0){ + $where = 'WHERE '; + foreach($output->conditions as $conditionGroup){ + $where .= $conditionGroup->toString(); + } + } - // TODO Make sure column values are escaped. Preferably directly from the cache file and not in here - $query = "UPDATE INTO $tableName ($columnsList) VALUES ($valuesList)"; - - return $query; - /*$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):''; + $query = "UPDATE $tableName SET $columnsList ".$where; + + $result = $this->_query ($query); - if ($result && !$this->transaction_started) { - @cubrid_commit ($this->fd); - } + if ($result && !$this->transaction_started) @cubrid_commit ($this->fd); return $result; - */ - } + } /** * @brief handles deleteAct **/ - function _executeDeleteAct($output){ + function _executeDeleteAct ($output) + { $query = ''; $select = 'DELETE '; @@ -737,23 +738,12 @@ $where .= $conditionGroup->toString(); } } - /* - $groupBy = ''; - if($output->groups) if($output->groups[0] !== "") - $groupBy = 'GROUP BY ' . implode(', ', $output->groups); - - $orderBy = ''; - if(count($output->orderby) > 0){ - $orderBy = 'ORDER BY '; - foreach($output->orderby as $order){ - $orderBy .= $order->toString() .', '; - } - $orderBy = substr($orderBy, 0, -2); - } - */ $query = $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy; - return $query; + $result = $this->_query ($query); + if ($result && !$this->transaction_started) @cubrid_commit ($this->fd); + + return $result; } /** @@ -775,9 +765,14 @@ $from = 'FROM '; $simple_table_count = 0; foreach($output->tables as $table){ - if($simple_table_count > 0) $from .= ', '; + /*if($simple_table_count > 0) $from .= ', '; + $from .= $table->toString() . ' '; if(!$table->isJoinTable()) $simple_table_count++; + */ + if($table->isJoinTable() || !$simple_table_count) $from .= $table->toString() . ' '; + else $from .= ', '.$table->toString() . ' '; + $simple_table_count++; } $where = ''; @@ -803,8 +798,18 @@ $query = $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy; - return $query; - } + + //$query = sprintf ("select %s from %s %s %s %s", $columns, implode (',',$table_list), implode (' ',$left_join), $condition, //$groupby_query.$orderby_query); + //$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):''; + $result = $this->_query ($query); + if ($this->isError ()) return; + $data = $this->_fetch ($result); + + $buff = new Object (); + $buff->data = $data; + + return $buff; + } /*function _executeSelectAct ($output) { // tables diff --git a/classes/xml/XmlQueryParser.class.php b/classes/xml/XmlQueryParser.class.php index fde5ade4d..8e1595056 100644 --- a/classes/xml/XmlQueryParser.class.php +++ b/classes/xml/XmlQueryParser.class.php @@ -36,7 +36,7 @@ if(!$this->dbParser){ //$oDB = &DB::getParser(); //$dbParser = $oDB->getParser(); - $this->dbParser = new DBParser('`'); + $this->dbParser = new DBParser('"'); } return $this->dbParser; } diff --git a/classes/xml/xmlquery/queryargument/DefaultValue.class.php b/classes/xml/xmlquery/queryargument/DefaultValue.class.php index 33f5776d3..060261b65 100644 --- a/classes/xml/xmlquery/queryargument/DefaultValue.class.php +++ b/classes/xml/xmlquery/queryargument/DefaultValue.class.php @@ -19,6 +19,7 @@ if(!isset($this->value)) return; $str_pos = strpos($this->value, '('); + // TODO Replace this with parseExpression if($str_pos===false) return '"'.$this->value.'"'; $func_name = substr($this->value, 0, $str_pos); diff --git a/classes/xml/xmlquery/queryargument/validator/QueryArgumentValidator.class.php b/classes/xml/xmlquery/queryargument/validator/QueryArgumentValidator.class.php index cfaeab5de..371dd33c3 100644 --- a/classes/xml/xmlquery/queryargument/validator/QueryArgumentValidator.class.php +++ b/classes/xml/xmlquery/queryargument/validator/QueryArgumentValidator.class.php @@ -25,8 +25,6 @@ $validator = ''; if(isset($this->default_value)){ $this->default_value = new DefaultValue($this->argument_name, $this->default_value); - //$v = new DefaultCheck($this->argument_name, $this->default_value); - //$validator .= $v->toString(); $validator .= sprintf("$%s_argument->ensureDefaultValue(%s);\n" , $this->argument_name , $this->default_value->toString() diff --git a/classes/xml/xmlquery/tags/navigation/IndexTag.class.php b/classes/xml/xmlquery/tags/navigation/IndexTag.class.php index afdfaa17c..cbe726b99 100644 --- a/classes/xml/xmlquery/tags/navigation/IndexTag.class.php +++ b/classes/xml/xmlquery/tags/navigation/IndexTag.class.php @@ -12,7 +12,7 @@ function IndexTag($index, $dbParser){ $this->dbParser = $dbParser; $this->argument_name = $index->attrs->var; - $index->attrs->default = $this->dbParser->parseExpression($index->attrs->default); + //$index->attrs->default = $this->dbParser->parseExpression($index->attrs->default); $this->default = $index->attrs->default; require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php'); $this->argument = new QueryArgument($index); @@ -23,7 +23,7 @@ $this->sort_order_argument = new QueryArgument($arg); $this->sort_order = "\$args->".$this->sort_order; } - //else $this->sort_order = '"'.$this->sort_order.'"'; + else $this->sort_order = '"'.$this->sort_order.'"'; } function toString(){ diff --git a/config/config.inc.php b/config/config.inc.php index 91ebb2fa1..24636abac 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -97,7 +97,7 @@ * 1: Enabled * Only particular servers may have a problem in IE browser when sending a compression **/ - if(!defined('__OB_GZHANDLER_ENABLE__')) define('__OB_GZHANDLER_ENABLE__', 1); + if(!defined('__OB_GZHANDLER_ENABLE__')) define('__OB_GZHANDLER_ENABLE__', 0); /** * @brief decide to use/not use the php unit test (Path/tests/index.php) diff --git a/modules/member/queries/getAutologin.xml b/modules/member/queries/getAutologin.xml index eef12f490..73065636b 100644 --- a/modules/member/queries/getAutologin.xml +++ b/modules/member/queries/getAutologin.xml @@ -10,6 +10,6 @@ - +