Fixed condition group bug - if there are more condition groups and the first doesn't get displayed, the pipe of the next is printed even though it shouldn't have been.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8607 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-07-18 15:58:46 +00:00
parent ff679cc517
commit 0c63c32b10
4 changed files with 42 additions and 2 deletions

View file

@ -190,8 +190,15 @@
function getWhereString($with_values = true){
$where = '';
if(count($this->conditions) > 0){
$condition_count = 0;
foreach($this->conditions as $conditionGroup){
$where .= $conditionGroup->toString($with_values);
$condition_string = $conditionGroup->toString($with_values);
if($condition_string !== '') $condition_count++;
if($condition_count === 1){
$conditionGroup->setPipe("");
$condition_string = $conditionGroup->toString($with_values);
}
$where .= $condition_string;
}
if(trim($where) == '') return '';

View file

@ -9,6 +9,10 @@
$this->pipe = $pipe;
}
function setPipe($pipe){
$this->pipe = $pipe;
}
function toString($with_value = true){
if($this->pipe !== "")
$group = $this->pipe .' (';

View file

@ -16,7 +16,18 @@
$output = executeQuery('module.getSiteInfo', $args);
$this->assertTrue(is_a($output, 'Object'));
$this->assertEquals(0, $output->error);
var_dump($output);
}
function test_document_getDocumentList_pagination(){
$args->sort_index = 'list_order';
$args->order_type = 'asc';
$args->page = 1;
$args->list_count = 30;
$args->page_count = 10;
$args->s_member_srl = 4;
$output = executeQuery('document.getDocumentList', $args);
$this->assertEquals(0, $output->error, $output->message);
}
}
?>

View file

@ -176,5 +176,23 @@
$this->assertTrue(is_int($output->page));
// $this->assertTrue($output->page == 5);
}
function test_document_getDocumentList(){
$xml_file = _XE_PATH_ . "modules/document/queries/getDocumentList.xml";
$argsString = '$args->sort_index = \'list_order\';
$args->order_type = \'asc\';
$args->page = 1;
$args->list_count = 30;
$args->page_count = 10;
$args->s_member_srl = 4;';
$expected = 'select *
from "xe_documents" as "documents"
where "member_srl" = 4
order by "list_order" asc
limit 0, 30';
$this->_test($xml_file, $argsString, $expected);
}
}