Skip to content

Commit

Permalink
Added ni condition
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Nov 9, 2016
1 parent ea50c04 commit d3756e4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function buildCondition($condition)
'eq' => 'buildEqCondition',
'ne' => 'buildNotEqCondition',
'in' => 'buildInCondition',
'ni' => 'buildNotInCondition',
'like' => 'buildLikeCondition',
'gt' => 'buildCompareCondition',
'ge' => 'buildCompareCondition',
Expand Down Expand Up @@ -177,7 +178,7 @@ private function buildBetweenCondition($operator, $operands)
throw new NotSupportedException('Between condition is not supported by HiArt.');
}

private function buildInCondition($operator, $operands)
private function buildInCondition($operator, $operands, $not = false)
{
if (!isset($operands[0], $operands[1])) {
throw new InvalidParamException("Operator '$operator' requires two operands.");
Expand All @@ -200,7 +201,17 @@ private function buildInCondition($operator, $operands)
}
}

return [$column . '_in' => $values];
if ($not) {
$key = $column . '_ni'; // not in
} else {
$key = $column . '_in';
}
return [$key => $values];
}

private function buildNotInCondition($operator, $operands)
{
return $this->buildInCondition($operator, $operands, true);
}

private function buildEqCondition($operator, $operands)
Expand Down

0 comments on commit d3756e4

Please sign in to comment.