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 ...@@ -561,27 +561,27 @@ class MysqliDb
foreach ($value[1] as $v) foreach ($value[1] as $v)
$this->_bindParam ($v); $this->_bindParam ($v);
break; break;
case 'not in':
case 'in': case 'in':
$comparison = ' IN ('; $comparison = ' ' . $key . ' (';
foreach($val as $v){ foreach($val as $v){
$comparison .= ' ?,'; $comparison .= ' ?,';
$this->_bindParam ($v); $this->_bindParam ($v);
} }
$comparison = rtrim($comparison, ',').' ) '; $comparison = rtrim($comparison, ',').' ) ';
break; break;
case 'not between':
case 'between': case 'between':
$comparison = ' BETWEEN ? AND ? '; $comparison = ' ' . $key . ' ? AND ? ';
$this->_bindParam ($val[0]); $this->_bindParam ($val[0]);
$this->_bindParam ($val[1]); $this->_bindParam ($val[1]);
break; break;
default: default:
// We are using a comparison operator with only one parameter after it // We are using a comparison operator with only one parameter after it
$comparison = ' '.$key.' ? '; $comparison = ' '.$key.' ? ';
// Determines what data type the where column is, for binding purposes.
$this->_bindParam ($val); $this->_bindParam ($val);
} }
} else { } else {
// Determines what data type the where column is, for binding purposes.
$comparison = ' = ? '; $comparison = ' = ? ';
$this->_bindParam ($value[1]); $this->_bindParam ($value[1]);
} }
......
...@@ -142,6 +142,7 @@ $results = $db->get('users'); ...@@ -142,6 +142,7 @@ $results = $db->get('users');
BETWEEN: BETWEEN:
```php ```php
$db->where('id', Array('between' => Array(4, 20) ) ); $db->where('id', Array('between' => Array(4, 20) ) );
//$db->where('id', Array('not between' => Array(4, 20) ) );
$results = $db->get('users'); $results = $db->get('users');
// Gives: SELECT * FROM users WHERE id BETWEEN 4 AND 20 // Gives: SELECT * FROM users WHERE id BETWEEN 4 AND 20
``` ```
...@@ -149,6 +150,7 @@ $results = $db->get('users'); ...@@ -149,6 +150,7 @@ $results = $db->get('users');
IN: IN:
```php ```php
$db->where('id', Array( 'in' => Array(1, 5, 27, -1, 'd') ) ); $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'); $results = $db->get('users');
// Gives: SELECT * FROM users WHERE id IN (1, 5, 27, -1, 'd'); // 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