From 393a7d2201eda623c27e1fb961357a81a89cad2a Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Mon, 2 May 2016 02:29:42 +0000 Subject: [PATCH] orm: Delegate ResultSet calls to QuerySet Iterator Allows for ability to access results without the need to call getIterator on the QuerySet. For example - $this->members->findFirst(array(...)); This commit addresses regression issue brought about by commits 8ab4432f and eb0ba31 -- where ResultSet processing changed based on caching mode. --- include/class.orm.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/class.orm.php b/include/class.orm.php index b784b6341..c234c5569 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -1310,6 +1310,16 @@ class QuerySet implements IteratorAggregate, ArrayAccess, Serializable, Countabl unset($this->count); } + function __call($name, $args) { + + if (!is_callable(array($this->getIterator(), $name))) + throw new OrmException('Call to undefined method QuerySet::'.$name); + + return $args + ? call_user_func_array(array($this->getIterator(), $name), $args) + : call_user_func(array($this->getIterator(), $name)); + } + // IteratorAggregate interface function getIterator($iterator=false) { if (!isset($this->_iterator)) { -- GitLab