Commit f96601ec authored by Alexander Butenko's avatar Alexander Butenko

Added not in and not between cases

parent 80d7b5ff
......@@ -561,27 +561,27 @@ class MysqliDb
foreach ($value[1] as $v)
$this->_bindParam ($v);
break;
case 'not in':
case 'in':
$comparison = ' IN (';
$comparison = ' ' . $key . ' (';
foreach($val as $v){
$comparison .= ' ?,';
$this->_bindParam ($v);
}
$comparison = rtrim($comparison, ',').' ) ';
break;
case 'not between':
case 'between':
$comparison = ' BETWEEN ? AND ? ';
$comparison = ' ' . $key . ' ? AND ? ';
$this->_bindParam ($val[0]);
$this->_bindParam ($val[1]);
break;
default:
// We are using a comparison operator with only one parameter after it
$comparison = ' '.$key.' ? ';
// Determines what data type the where column is, for binding purposes.
$this->_bindParam ($val);
}
} else {
// Determines what data type the where column is, for binding purposes.
$comparison = ' = ? ';
$this->_bindParam ($value[1]);
}
......
......@@ -142,6 +142,7 @@ $results = $db->get('users');
BETWEEN:
```php
$db->where('id', Array('between' => Array(4, 20) ) );
//$db->where('id', Array('not between' => Array(4, 20) ) );
$results = $db->get('users');
// Gives: SELECT * FROM users WHERE id BETWEEN 4 AND 20
```
......@@ -149,6 +150,7 @@ $results = $db->get('users');
IN:
```php
$db->where('id', Array( 'in' => Array(1, 5, 27, -1, 'd') ) );
//$db->where('id', Array( 'not in' => Array(1, 5, 27, -1, 'd') ) );
$results = $db->get('users');
// Gives: SELECT * FROM users WHERE id IN (1, 5, 27, -1, 'd');
```
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment