Skip to content

Commit ab034b4

Browse files
committed
where can now specify operator (<, >, etc) by passing an array of conditions with the operator as the first element, and the value as the second
1 parent 27e8263 commit ab034b4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Chimera/Storage/MySQL/Query.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,19 @@ public function sql() {
8383
$where = '';
8484
if (!empty($this->_conditions)) {
8585
$where = 'WHERE ';
86-
foreach ($this->_conditions as $set) {
86+
foreach ($this->_conditions as $k => $set) {
8787
$placeholders = array();
8888
foreach ($set['conditions'] as $key => $value) {
89-
$placeholders[] = " $key=? ";
89+
$op = '=';
90+
if (is_array($value)) {
91+
$op = $value[0];
92+
$this->_conditions[$k]['conditions'][$key] = $value[1];
93+
}
94+
$placeholders[] = " {$key}{$op}? ";
9095
}
9196
$where .= '(' . join($set['type'], $placeholders) . ')';
9297
}
9398
}
94-
9599
$limit = '';
96100
if (!empty($this->_limit)) {
97101
$limit = 'LIMIT '

0 commit comments

Comments
 (0)