summaryrefslogtreecommitdiff
path: root/idiorm.php
diff options
context:
space:
mode:
authorSimon Holywell <[email protected]>2014-05-28 15:25:18 +0100
committerSimon Holywell <[email protected]>2014-05-28 15:25:18 +0100
commit9b3b9caa2232c097cbfff153e9c8f99d72248049 (patch)
treed29bdcd9deaec5ee9aa0d1cc07b2cd17359ff267 /idiorm.php
parentde4a611d5c3676e3b505c4a6812ccc91ec049d61 (diff)
parentdb071216909799fcc781f9257065f7411214c169 (diff)
Merge pull request #202 from lrlopez/where_id_in-2
where_id_in() for selecting multiple records by primary key
Diffstat (limited to 'idiorm.php')
-rw-r--r--idiorm.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/idiorm.php b/idiorm.php
index ff0ff6e..73072e6 100644
--- a/idiorm.php
+++ b/idiorm.php
@@ -1173,6 +1173,18 @@
return $filtered;
}
+ /**
+ * Helper method that filters an array containing compound column/value
+ * arrays.
+ */
+ protected function _get_compound_id_column_values_array($values) {
+ $filtered = array();
+ foreach($values as $value) {
+ $filtered[] = $this->_get_compound_id_column_values($value);
+ }
+ return $filtered;
+ }
+
/**
* Add a WHERE column = value clause to your query. Each time
* this is called in the chain, an additional WHERE will be
@@ -1251,6 +1263,18 @@
}
/**
+ * Similar to where_id_is() but allowing multiple primary keys.
+ *
+ * If primary key is compound, only the columns that
+ * belong to they key will be used for the query
+ */
+ public function where_id_in($ids) {
+ return (is_array($this->_get_id_column_name())) ?
+ $this->where_any_is($this->_get_compound_id_column_values_array($ids)) :
+ $this->where_in($this->_get_id_column_name(), $ids);
+ }
+
+ /**
* Add a WHERE ... LIKE clause to your query.
*/
public function where_like($column_name, $value=null) {