Skip to content

Commit

Permalink
fix negative search
Browse files Browse the repository at this point in the history
  • Loading branch information
mgaoVA committed Nov 2, 2023
1 parent 9f950e0 commit a3067fe
Showing 1 changed file with 32 additions and 27 deletions.
59 changes: 32 additions & 27 deletions LEAF_Request_Portal/sources/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -3261,48 +3261,53 @@ public function query(string $inQuery): mixed
{
$dataTerm = 'lj_data.data';
}
$dataTermSql = '';

$dataMatch = ":data{$count}";
switch ($tResTypeHint[0]['format']) {
case 'number':
case 'currency':
$dataTerm = "CAST({$dataTerm} as DECIMAL(21,5))";
case 'number':
case 'currency':
$dataTermSql = "CAST({$dataTerm} as DECIMAL(21,5))";

break;
case 'date':
$dataTerm = "STR_TO_DATE({$dataTerm}, '%m/%d/%Y')";
$dataMatch = "STR_TO_DATE(:data{$count}, '%m/%d/%Y')";

break;
default:
if($operator == 'MATCH ALL') {
$vars[":data{$count}"] = $this->parseBooleanQuery($vars[":data{$count}"]);
}
break;
case 'date':
$dataTermSql = "STR_TO_DATE({$dataTerm}, '%m/%d/%Y')";
$dataMatch = "STR_TO_DATE(:data{$count}, '%m/%d/%Y')";

if(strpos($operator, 'MATCH') !== false) {
if($operator == 'NOT MATCH') {
$dataTerm = "NOT MATCH ({$dataTerm})";
}
else {
$dataTerm = "MATCH ({$dataTerm})";
break;
default:
if($operator == 'MATCH ALL') {
$vars[":data{$count}"] = $this->parseBooleanQuery($vars[":data{$count}"]);
}

$operator = 'AGAINST';
$dataMatch = "({$dataMatch} IN BOOLEAN MODE)";
}
break;
}
if(strpos($operator, 'MATCH') !== false) {
if($operator == 'NOT MATCH') {
$dataTermSql = "NOT MATCH ({$dataTerm})";
}
else {
$dataTermSql = "MATCH ({$dataTerm})";
}

$operator = 'AGAINST';
$dataMatch = "({$dataMatch} IN BOOLEAN MODE)";
}
break;
}

if($dataTermSql == '') {
$dataTermSql = $dataTerm;
}
// catch default data
if ((isset($tResTypeHint[0]['default'])
&& $tResTypeHint[0]['default'] == $vars[':data' . $count])
|| $operator == 'NOT LIKE')
|| $q['operator'] == 'NOT LIKE'
|| $q['operator'] == 'NOT MATCH')
{
$conditions .= "{$gate}({$dataTerm} {$operator} $dataMatch OR {$dataTerm} IS NULL)";
$conditions .= "{$gate}({$dataTermSql} {$operator} $dataMatch OR {$dataTerm} IS NULL)";
}
else
{
$conditions .= "{$gate}{$dataTerm} {$operator} $dataMatch";
$conditions .= "{$gate}{$dataTermSql} {$operator} $dataMatch";
}
}
}
Expand Down

0 comments on commit a3067fe

Please sign in to comment.