diff options
-rw-r--r-- | it_dbi.class | 3 | ||||
-rwxr-xr-x | tests/it_dbi.t | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/it_dbi.class b/it_dbi.class index 06e1d1e..328e63c 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -264,6 +264,7 @@ function _set($tags, $allfields = false) * Example: * $sql = $table->_where(array('Type' => 'bar', * 'Date >=' => '1999-01-01', '-Date <' => 'NOW()', + * 'Status' => array('foo', 'bar', 'qux'), # same as 'Status IN' => ... * 'User NI' => 'chris'), 'ORDER BY Date'); * * @param $params optional array of fieldname => value tupels. These are ANDed to form a WHERE clause. @@ -309,7 +310,7 @@ function _where($params = "", $dummy_link = null, $omit_where = false) $op = strtoupper($regs[2]); } else - $op = '='; + $op = is_array($value) ? 'IN' : '='; # If field name starts with '-', the raw value is taken, no escaping is done and no quotes are put around it. if (substr($field, 0, 1) == '-') diff --git a/tests/it_dbi.t b/tests/it_dbi.t index ecd40e3..762e81f 100755 --- a/tests/it_dbi.t +++ b/tests/it_dbi.t @@ -73,6 +73,11 @@ is( 3, "select with empty NOT IN" ); +is( + $record->select(array('ID' => array(2,3))), + 2, + "select with implicit IN" +); it_dbi::createclass(array('table' => "it_dbi_test", 'forcecreate' => true)); |