diff options
Diffstat (limited to 'idiorm.php')
-rw-r--r-- | idiorm.php | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -334,6 +334,14 @@ } /** + * Return a string containing the given number of question marks, + * separated by commas. Eg "?, ?, ?" + */ + protected function _create_placeholders($number_of_placeholders) { + return join(", ", array_fill(0, $number_of_placeholders, "?")); + } + + /** * Add a WHERE column = value clause to your query. Each time * this is called in the chain, an additional WHERE will be * added, and these will be ANDed together when the final query @@ -394,6 +402,24 @@ } /** + * Add a WHERE ... IN clause to your query + */ + public function where_in($column_name, $values) { + $column_name = $this->_quote_identifier($column_name); + $placeholders = $this->_create_placeholders(count($values)); + return $this->_add_where("{$column_name} IN ({$placeholders})", $values); + } + + /** + * Add a WHERE ... NOT IN clause to your query + */ + public function where_not_in($column_name, $values) { + $column_name = $this->_quote_identifier($column_name); + $placeholders = $this->_create_placeholders(count($values)); + return $this->_add_where("{$column_name} NOT IN ({$placeholders})", $values); + } + + /** * Add a raw WHERE clause to the query. The clause should * contain question mark placeholders, which will be bound * to the parameters supplied in the second argument. |