summaryrefslogtreecommitdiff
path: root/idiorm.php
diff options
context:
space:
mode:
authorJamie Matthews <[email protected]>2010-11-01 23:18:03 +0000
committerJamie Matthews <[email protected]>2010-11-01 23:18:03 +0000
commite86cd738287a8e36ed1ecbcb9197fa22b851f271 (patch)
treee36fd7071a64284d1deab77c421dc713fe9f9108 /idiorm.php
parent518fee9a9b32ce7a8effc348b99d8f82690abe58 (diff)
Add as_array method to return raw data wrapped by ORM instances
Diffstat (limited to 'idiorm.php')
-rw-r--r--idiorm.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/idiorm.php b/idiorm.php
index 58de3b9..e4e9ab6 100644
--- a/idiorm.php
+++ b/idiorm.php
@@ -807,6 +807,20 @@
}
/**
+ * Return the raw data wrapped by this ORM
+ * instance as an associative array. Column
+ * names may optionally be supplied as arguments,
+ * if so, only those keys will be returned.
+ */
+ public function as_array() {
+ if (func_num_args() === 0) {
+ return $this->_data;
+ }
+ $args = func_get_args();
+ return array_intersect_key($this->_data, array_flip($args));
+ }
+
+ /**
* Return the value of a property of this object (database row)
* or null if not present.
*/