summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Holywell <[email protected]>2013-01-16 10:29:50 +0000
committerSimon Holywell <[email protected]>2013-01-16 10:29:50 +0000
commit5edfadfc5a9aa535d5c3f0991f3dcff5df7380ba (patch)
tree9cf7c1f6e9b54fe0427c98e9949a6ee44ca3bfaa
parent5a6d20c7c41c26f6b2db3d518853d931a4c53445 (diff)
Add ArrayAccess and Serializable to Idiorm
-rw-r--r--idiorm.php54
1 files changed, 53 insertions, 1 deletions
diff --git a/idiorm.php b/idiorm.php
index ac2e033..5b5ebde 100644
--- a/idiorm.php
+++ b/idiorm.php
@@ -1787,7 +1787,7 @@
* A result set class for working with collections of model instances
* @author Simon Holywell <[email protected]>
*/
- class IdiormResultSet implements Countable, IteratorAggregate {
+ class IdiormResultSet implements Countable, IteratorAggregate, ArrayAccess, Serializable {
/**
* The current result set as an array
* @var array
@@ -1844,6 +1844,58 @@
}
/**
+ * ArrayAccess
+ * @param int|string $offset
+ * @return bool
+ */
+ public function offsetExists($offset) {
+ return isset($this->_results[$offset]);
+ }
+
+ /**
+ * ArrayAccess
+ * @param int|string $offset
+ * @return mixed
+ */
+ public function offsetGet($offset) {
+ return $this->_results[$offset];
+ }
+
+ /**
+ * ArrayAccess
+ * @param int|string $offset
+ * @param mixed $value
+ */
+ public function offsetSet($offset, $value) {
+ $this->_results[$offset] = $value;
+ }
+
+ /**
+ * ArrayAccess
+ * @param int|string $offset
+ */
+ public function offsetUnset($offset) {
+ unset($this->_results[$offset]);
+ }
+
+ /**
+ * Serializable
+ * @return string
+ */
+ public function serialize() {
+ return serialize($this->_results);
+ }
+
+ /**
+ * Serializable
+ * @param string $serialized
+ * @return array
+ */
+ public function unserialize($serialized) {
+ return unserialize($serialized);
+ }
+
+ /**
* Call a method on all models in a result set. This allows for method
* chaining such as setting a property on all models in a result set or
* any other batch operation across models.