Skip to content

Commit eec9134

Browse files
committed
Update ezQuery.php
1 parent 248e47a commit eec9134

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

lib/ezQuery.php

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,24 @@ private function retrieveConditions($whereConditions)
367367
return [$operator, $whereClause, $combiner, $extra];
368368
}
369369

370+
private function processConditions($column, $condition, $value, $valueOrCombine, $extraCombine)
371+
{
372+
if (! \in_array( $condition, \_BOOLEAN_OPERATORS))
373+
return $this->clearPrepare();
374+
375+
if (($condition == \_BETWEEN) || ($condition == \_notBETWEEN)) {
376+
$this->conditionBetween($column, $condition, $value, $valueOrCombine, $extraCombine);
377+
} elseif ($condition == \_IN) {
378+
$this->conditionIn($column, $condition, $value, $valueOrCombine);
379+
} elseif (((\strtolower($value) == 'null') || ($condition == 'IS') || ($condition == 'IS NOT'))) {
380+
$this->conditionIs($column, $condition, $valueOrCombine);
381+
} elseif ((($condition == \_LIKE) || ($condition == \_notLIKE)) && ! \preg_match('/[_%?]/', $value)) {
382+
return $this->clearPrepare();
383+
} else {
384+
$this->conditions($column, $condition, $value, $valueOrCombine);
385+
}
386+
}
387+
370388
public function where( ...$whereConditions)
371389
{
372390
if (empty($whereConditions))
@@ -377,8 +395,7 @@ public function where( ...$whereConditions)
377395

378396
$this->combineWith = '';
379397

380-
if (\is_string($whereConditions[0])
381-
&& ((\strpos($whereConditions[0], 'WHERE') !== false) || (\strpos($whereConditions[0], 'HAVING') !== false)))
398+
if (\is_string($whereConditions[0]) && \strpos($whereConditions[0], $whereOrHaving) !== false)
382399
return $whereConditions[0];
383400

384401
list($operator, $whereClause, $combiner, $extra) = $this->retrieveConditions($whereConditions);
@@ -391,25 +408,13 @@ public function where( ...$whereConditions)
391408
$i = 0;
392409
foreach($whereClause as $key => $val) {
393410
$isCondition = \strtoupper($operator[$i]);
394-
if (! \in_array( $isCondition, \_BOOLEAN_OPERATORS))
395-
return $this->clearPrepare();
396-
397411
$combine = $combiner[$i];
398412
$this->combineWith = \_AND;
399413
if ( \in_array(\strtoupper($combine), \_COMBINERS) || isset($extra[$i]))
400414
$this->combineWith = isset($extra[$i]) ? $combine : \strtoupper($combine);
401415

402-
if (($isCondition == \_BETWEEN) || ($isCondition == \_notBETWEEN)) {
403-
$this->conditionBetween($key, $isCondition, $val, $this->combineWith, $extra[$i]);
404-
} elseif ($isCondition == \_IN) {
405-
$this->conditionIn($key, $isCondition, $val, $this->combineWith);
406-
} elseif (((\strtolower($val) == 'null') || ($isCondition == 'IS') || ($isCondition == 'IS NOT'))) {
407-
$this->conditionIs($key, $isCondition, $this->combineWith);
408-
} elseif ((($isCondition == \_LIKE) || ($isCondition == \_notLIKE)) && ! \preg_match('/[_%?]/', $val)) {
409-
return $this->clearPrepare();
410-
} else {
411-
$this->conditions($key, $isCondition, $val, $this->combineWith);
412-
}
416+
if ($this->processConditions($key, $isCondition, $val, $this->combineWith, $extra[$i]) === false)
417+
return false;
413418

414419
$i++;
415420
}

0 commit comments

Comments
 (0)