mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-21 12:19:56 +09:00
Issue 1431: xml query click_count error - fixed missing class error, added unit tests
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.3.2@12017 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
bbcef7ad51
commit
f93d0d289d
10 changed files with 112 additions and 45 deletions
|
|
@ -13,6 +13,7 @@
|
|||
require(_XE_PATH_.'classes/db/queryparts/expression/InsertExpression.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpression.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/expression/ClickCountExpression.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/table/Table.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/table/JoinTable.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/table/CubridTableWithHint.class.php');
|
||||
|
|
|
|||
|
|
@ -56,13 +56,13 @@
|
|||
* argument list
|
||||
* @var array
|
||||
*/
|
||||
var $arguments = null;
|
||||
var $arguments = NULL;
|
||||
|
||||
/**
|
||||
* column list
|
||||
* @var array
|
||||
*/
|
||||
var $columnList = null;
|
||||
var $columnList = NULL;
|
||||
|
||||
/**
|
||||
* order by text
|
||||
|
|
@ -83,15 +83,15 @@
|
|||
* @param string $priority
|
||||
* @return void
|
||||
*/
|
||||
function Query($queryID = null
|
||||
, $action = null
|
||||
, $columns = null
|
||||
, $tables = null
|
||||
, $conditions = null
|
||||
, $groups = null
|
||||
, $orderby = null
|
||||
, $limit = null
|
||||
, $priority = null){
|
||||
function Query($queryID = NULL
|
||||
, $action = NULL
|
||||
, $columns = NULL
|
||||
, $tables = NULL
|
||||
, $conditions = NULL
|
||||
, $groups = NULL
|
||||
, $orderby = NULL
|
||||
, $limit = NULL
|
||||
, $priority = NULL){
|
||||
$this->queryID = $queryID;
|
||||
$this->action = $action;
|
||||
$this->priority = $priority;
|
||||
|
|
@ -106,7 +106,7 @@
|
|||
}
|
||||
|
||||
function show(){
|
||||
return true;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function setQueryId($queryID){
|
||||
|
|
@ -149,7 +149,7 @@
|
|||
|
||||
function setTables($tables){
|
||||
if(!isset($tables) || count($tables) === 0){
|
||||
$this->setError(true);
|
||||
$this->setError(TRUE);
|
||||
$this->setMessage("You must provide at least one table for the query.");
|
||||
return;
|
||||
}
|
||||
|
|
@ -158,10 +158,10 @@
|
|||
|
||||
$this->tables = $tables;
|
||||
}
|
||||
|
||||
function setSubquery($subquery){
|
||||
$this->subquery = $subquery;
|
||||
}
|
||||
|
||||
function setSubquery($subquery){
|
||||
$this->subquery = $subquery;
|
||||
}
|
||||
|
||||
function setConditions($conditions){
|
||||
$this->conditions = array();
|
||||
|
|
@ -198,7 +198,7 @@
|
|||
* @param string|array $columns
|
||||
* @return Query return Query instance
|
||||
*/
|
||||
function select($columns= null){
|
||||
function select($columns= NULL){
|
||||
$this->action = 'select';
|
||||
$this->setColumns($columns);
|
||||
return $this;
|
||||
|
|
@ -263,12 +263,28 @@
|
|||
return $this->priority?'LOW_PRIORITY':'';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current query uses the click count attribute
|
||||
* For CUBRID, this statement uses the click count feature.
|
||||
* For the other databases, using this attribute causes a query
|
||||
* to produce both a select and an update
|
||||
*/
|
||||
function usesClickCount()
|
||||
{
|
||||
foreach($this->columns as $column){
|
||||
if($column->show() && $column instanceof ClickCountExpression)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return select sql
|
||||
* @param boolean $with_values
|
||||
* @return string
|
||||
*/
|
||||
function getSelectString($with_values = true){
|
||||
function getSelectString($with_values = TRUE){
|
||||
$select = array();
|
||||
foreach($this->columns as $column){
|
||||
if($column->show())
|
||||
if($column->isSubquery()){
|
||||
|
|
@ -285,7 +301,7 @@
|
|||
* @param boolean $with_values
|
||||
* @return string
|
||||
*/
|
||||
function getUpdateString($with_values = true){
|
||||
function getUpdateString($with_values = TRUE){
|
||||
foreach($this->columns as $column){
|
||||
if($column->show())
|
||||
$update[] = $column->getExpression($with_values);
|
||||
|
|
@ -298,22 +314,22 @@
|
|||
* @param boolean $with_values
|
||||
* @return string
|
||||
*/
|
||||
function getInsertString($with_values = true){
|
||||
function getInsertString($with_values = TRUE){
|
||||
$columnsList = '';
|
||||
if($this->subquery){ // means we have insert-select
|
||||
|
||||
foreach($this->columns as $column){
|
||||
$columnsList .= $column->getColumnName() . ', ';
|
||||
}
|
||||
$columnsList = substr($columnsList, 0, -2);
|
||||
|
||||
$selectStatement = $this->subquery->toString($with_values);
|
||||
$selectStatement = substr($selectStatement, 1, -1);
|
||||
|
||||
return "($columnsList) \n $selectStatement";
|
||||
}
|
||||
|
||||
|
||||
if($this->subquery){ // means we have insert-select
|
||||
|
||||
foreach($this->columns as $column){
|
||||
$columnsList .= $column->getColumnName() . ', ';
|
||||
}
|
||||
$columnsList = substr($columnsList, 0, -2);
|
||||
|
||||
$selectStatement = $this->subquery->toString($with_values);
|
||||
$selectStatement = substr($selectStatement, 1, -1);
|
||||
|
||||
return "($columnsList) \n $selectStatement";
|
||||
}
|
||||
|
||||
|
||||
$valuesList = '';
|
||||
foreach($this->columns as $column){
|
||||
if($column->show()){
|
||||
|
|
@ -339,7 +355,7 @@
|
|||
* @param boolean $with_values
|
||||
* @return string
|
||||
*/
|
||||
function getFromString($with_values = true){
|
||||
function getFromString($with_values = TRUE){
|
||||
$from = '';
|
||||
$simple_table_count = 0;
|
||||
foreach($this->tables as $table){
|
||||
|
|
@ -360,7 +376,7 @@
|
|||
* @param boolean $with_optimization
|
||||
* @return string
|
||||
*/
|
||||
function getWhereString($with_values = true, $with_optimization = true){
|
||||
function getWhereString($with_values = TRUE, $with_optimization = TRUE){
|
||||
$where = '';
|
||||
$condition_count = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@
|
|||
parent::SelectExpression($column_name, $alias);
|
||||
|
||||
if(!is_bool($click_count)){
|
||||
error_log("Click_count value for $column_name was not boolean", 0);
|
||||
// error_log("Click_count value for $column_name was not boolean", 0);
|
||||
$this->click_count = false;
|
||||
return;
|
||||
}
|
||||
$this->click_count = $click_count;
|
||||
}
|
||||
|
|
@ -39,7 +38,15 @@
|
|||
* @return string
|
||||
*/
|
||||
function getExpression(){
|
||||
return "$this->column_name = $this->column_name + 1";
|
||||
$db_type = Context::getDBType();
|
||||
if($db_type == 'cubrid')
|
||||
{
|
||||
return "INCR($this->column_name)";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "$this->column_name";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@
|
|||
function getExpressionString(){
|
||||
if($this->name == '*') return "new StarExpression()";
|
||||
if($this->click_count)
|
||||
return sprintf('new ClickCountExpression(%s, %s, $args->%s)', $this->name, $this->alias,$this->click_count);
|
||||
return sprintf('new ClickCountExpression(\'%s\', %s, $args->%s)', $this->name, $this->alias ? '\'' . $this->alias . '\'' : "''",$this->click_count);
|
||||
if(strpos($this->name, '$') === 0)
|
||||
return sprintf('new SelectExpression($args->%s)', substr($this->name, 1));
|
||||
return sprintf('new SelectExpression($args->%s)', substr($this->name, 1));
|
||||
$dbParser = DB::getParser();
|
||||
return sprintf('new SelectExpression(\'%s\'%s)', $this->name, $this->alias ? ', \''.$dbParser->escape($this->alias) .'\'': '');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue