* [misc] add quote for getCondition.

This commit is contained in:
qixinzhi
2025-06-18 01:44:13 +00:00
parent c9c2fb2e63
commit 868a541816
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";