diff options
-rw-r--r-- | idiorm.php | 54 |
1 files changed, 53 insertions, 1 deletions
@@ -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. |