mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Fix invalid query when search contains zero conditions #2687
This commit is contained in:
parent
e61ccf84b8
commit
63d2582c8e
1 changed files with 22 additions and 8 deletions
|
|
@ -254,8 +254,11 @@ class VariableBase
|
|||
break;
|
||||
case 'search':
|
||||
$parsed_keywords = $this->_parseSearchKeywords($column, $value);
|
||||
$where = $parsed_keywords[0];
|
||||
$params = array_merge($params, $parsed_keywords[1]);
|
||||
if (count($parsed_keywords))
|
||||
{
|
||||
$where = $parsed_keywords[0];
|
||||
$params = array_merge($params, $parsed_keywords[1]);
|
||||
}
|
||||
break;
|
||||
case 'plus':
|
||||
$where = sprintf('%s = %s + %s', $column, $column, $is_expression ? $value : '?');
|
||||
|
|
@ -521,9 +524,12 @@ class VariableBase
|
|||
if ($item !== '')
|
||||
{
|
||||
$parsed_keywords = $this->_parseSearchKeywords($column, $item);
|
||||
$conditions[] = $parsed_keywords[0];
|
||||
$conditions[] = 'AND';
|
||||
$params = array_merge($params, $parsed_keywords[1]);
|
||||
if (count($parsed_keywords))
|
||||
{
|
||||
$conditions[] = $parsed_keywords[0];
|
||||
$conditions[] = 'AND';
|
||||
$params = array_merge($params, $parsed_keywords[1]);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -563,9 +569,17 @@ class VariableBase
|
|||
|
||||
// remove the last point (would be an operator)
|
||||
array_pop($conditions);
|
||||
$conditions = implode(' ', $conditions);
|
||||
$where = count($keywords) === 1 ? $conditions : "($conditions)";
|
||||
|
||||
return [$where, $params];
|
||||
// combine the conditions and return
|
||||
if (count($params) === 0)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
else
|
||||
{
|
||||
$conditions = implode(' ', $conditions);
|
||||
$where = count($params) === 1 ? $conditions : "($conditions)";
|
||||
return [$where, $params];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue