Merge branch release/21.7.2 of zentao/zentaopms (#9615)

This commit is contained in:
刘刚
2025-06-18 10:50:23 +08:00
committed by Gitfox
4 changed files with 15 additions and 13 deletions
+5 -3
View File
@@ -301,7 +301,7 @@ class sqlparser
* @access public
* @return object
*/
public function getCondition($tableA = null, $columnA = null, $operator = '', $tableB = null, $columnB = null, $group = 1)
public function getCondition($tableA = null, $columnA = null, $operator = '', $tableB = null, $columnB = null, $group = 1, $quote = true)
{
if(is_array($tableA)) return call_user_func_array(array($this, 'getCondition'), $tableA);
@@ -323,8 +323,10 @@ class sqlparser
/* 如果tableB为空,那么columnB是值,需要trim("'")。*/
if(empty($tableB)) $columnB = $this->trimExpr($columnB, "'");
$exprA = empty($tableA) ? "`$columnA`" : "`$tableA`.`$columnA`";
$exprB = empty($tableB) ? "'$columnB'" : "`$tableB`.`$columnB`";
$columnB = empty($tableB) && $quote ? "'$columnB'" : $columnB;
$exprA = empty($tableA) ? "`$columnA`" : "`$tableA`.`$columnA`";
$exprB = empty($tableB) ? $columnB : "`$tableB`.`$columnB`";
$operator = strtoupper($operator);
$expr = "$exprA $operator $exprB";
+2 -2
View File
@@ -1463,12 +1463,12 @@ class biModel extends model
* @access public
* @return object
*/
public function getCondition(mixed $tableA = null, mixed $columnA = null, string $operator = '', mixed $tableB = null, mixed $columnB = null, int $group = 1): object
public function getCondition(mixed $tableA = null, mixed $columnA = null, string $operator = '', mixed $tableB = null, mixed $columnB = null, int $group = 1, bool $quote = true): object
{
$this->app->loadClass('sqlparser', true);
$parser = new sqlparser(null);
return $parser->getCondition($tableA, $columnA, $operator, $tableB, $columnB, $group);
return $parser->getCondition($tableA, $columnA, $operator, $tableB, $columnB, $group, $quote);
}
/**
+2 -2
View File
@@ -60,9 +60,9 @@ class biTest
* @access public
* @return string
*/
public function getConditionTest(mixed $tableA = null, mixed $columnA = null, string $operator = '', mixed $tableB = null, mixed $columnB = null, int $group = 1): string
public function getConditionTest(mixed $tableA = null, mixed $columnA = null, string $operator = '', mixed $tableB = null, mixed $columnB = null, int $group = 1, bool $quote = true): string
{
$condition = $this->objectModel->getCondition($tableA, $columnA, $operator, $tableB, $columnB, $group);
$condition = $this->objectModel->getCondition($tableA, $columnA, $operator, $tableB, $columnB, $group, $quote);
return $condition->build($condition);
}
+6 -6
View File
@@ -24,14 +24,14 @@ cid=1
*/
$bi = new biTest();
r($bi->getConditionTest(null, 'deleted', '=', null, "'0'")) && p('') && e("`deleted` = '0'"); // 测试 `deleted` = '0'
r($bi->getConditionTest('t1', 'deleted', '=', null, "'0'")) && p('') && e("`t1`.`deleted` = '0'"); // 测试 `t1`.`deleted` = '0'
r($bi->getConditionTest(null, 'deleted', '=', null, "0")) && p('') && e("`deleted` = '0'"); // 测试 `deleted` = '0'
r($bi->getConditionTest('t1', 'deleted', '=', null, "0")) && p('') && e("`t1`.`deleted` = '0'"); // 测试 `t1`.`deleted` = '0'
r($bi->getConditionTest('t1', 'project', '=', 't2', 'id')) && p('') && e("`t1`.`project` = `t2`.`id`"); // 测试 `t1`.`project` = `t2`.`id`
r($bi->getConditionTest('`t1`', '`project`', '=', 't2', 'id')) && p('') && e("`t1`.`project` = `t2`.`id`"); // 测试 `t1`.`project` = `t2`.`id`
r($bi->getConditionTest('`t1`', '`project` ', '=', 't2', 'id')) && p('') && e("`t1`.`project` = `t2`.`id`"); // 测试 `t1`.`project` = `t2`.`id`
r($bi->getConditionTest('t1', 'type', 'in', null, "('sprint', 'stage', 'kanban')")) && p('') && e("`t1`.`type` IN ('sprint', 'stage', 'kanban')"); // 测试 `t1`.`type` IN ('sprint', 'stage', 'kanban')
r($bi->getConditionTest('t1', 'type', 'not in', null, "('sprint', 'stage', 'kanban')")) && p('') && e("`t1`.`type` NOT IN ('sprint', 'stage', 'kanban')"); // 测试 `t1`.`type` NOT IN ('sprint', 'stage', 'kanban')
r($bi->getConditionTest('t1', 'type', 'in', null, "('sprint', 'stage', 'kanban')", 1, false)) && p('') && e("`t1`.`type` IN ('sprint', 'stage', 'kanban')"); // 测试 `t1`.`type` IN ('sprint', 'stage', 'kanban')
r($bi->getConditionTest('t1', 'type', 'not in', null, "('sprint', 'stage', 'kanban')", 1, false)) && p('') && e("`t1`.`type` NOT IN ('sprint', 'stage', 'kanban')"); // 测试 `t1`.`type` NOT IN ('sprint', 'stage', 'kanban')
r($bi->getConditionTest('t1', 'name', 'is', null, 'not null')) && p('') && e("`t1`.`name` IS not null"); // 测试 `t1`.`name` IS not null
r($bi->getConditionTest('t1', 'name', 'is', null, 'null')) && p('') && e("`t1`.`name` IS null"); // 测试 `t1`.`name` IS not null`t1`.`name` IS null
r($bi->getConditionTest('t1', 'name', 'is', null, 'not null', 1, false)) && p('') && e("`t1`.`name` IS not null"); // 测试 `t1`.`name` IS not null
r($bi->getConditionTest('t1', 'name', 'is', null, 'null', 1, false)) && p('') && e("`t1`.`name` IS null"); // 测试 `t1`.`name` IS not null`t1`.`name` IS null