From e86cd738287a8e36ed1ecbcb9197fa22b851f271 Mon Sep 17 00:00:00 2001 From: Jamie Matthews Date: Mon, 1 Nov 2010 23:18:03 +0000 Subject: Add as_array method to return raw data wrapped by ORM instances --- idiorm.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'idiorm.php') diff --git a/idiorm.php b/idiorm.php index 58de3b9..e4e9ab6 100644 --- a/idiorm.php +++ b/idiorm.php @@ -806,6 +806,20 @@ return $statement; } + /** + * 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. -- cgit v1.2.3