Skip to content

Commit

Permalink
Support ->where("NOT id", array()), BC break: unsupport "id NOT"
Browse files Browse the repository at this point in the history
  • Loading branch information
vrana committed Jun 14, 2011
1 parent c29ef5f commit 2593db8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions NotORM/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ function where($condition, $parameters = array()) {
if ($in) {
$condition .= " IN (" . implode(", ", $in) . ")";
} else {
$condition .= " IN (NULL)";
$condition = "($condition) IS NOT NULL AND $condition IS NULL"; // $condition = "NOT id"
}
}
} elseif (!is_array($parameters)) { // where("column", "x")
Expand All @@ -361,7 +361,7 @@ function where($condition, $parameters = array()) {
if ($parameters) {
$condition .= " IN (" . implode(", ", array_map(array($this, 'quote'), $parameters)) . ")";
} else {
$condition .= " IN (NULL)";
$condition = "($condition) IS NOT NULL AND $condition IS NULL";
}
}
$this->where[] = $condition;
Expand Down
16 changes: 16 additions & 0 deletions tests/26-in.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
IN operator
--FILE--
<?php
include_once dirname(__FILE__) . "/connect.inc.php";

echo $software->application("maintainer_id", array())->count("*") . "\n";
echo $software->application("maintainer_id", array(11))->count("*") . "\n";
echo $software->application("NOT maintainer_id", array(11))->count("*") . "\n";
echo $software->application("NOT maintainer_id", array())->count("*") . "\n";
?>
--EXPECTF--
0
1
2
3

0 comments on commit 2593db8

Please sign in to comment.