From 46e90a1fd4fac50308b54ce6e6e4589f3d387272 Mon Sep 17 00:00:00 2001 From: Gerben Date: Wed, 22 May 2019 10:31:33 +0200 Subject: [PATCH] Return a value from prefetch if result is false --- src/CachedPersistenceModel.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/CachedPersistenceModel.php b/src/CachedPersistenceModel.php index df36065..aa98acc 100644 --- a/src/CachedPersistenceModel.php +++ b/src/CachedPersistenceModel.php @@ -181,7 +181,7 @@ protected function cacheResult($result_set, $memcache = false) { * @param string $order_by ORDER BY * @param int $limit max amount of results * @param int $start results from index - * @return array + * @return array|boolean */ public function prefetch( $criteria = null, @@ -211,9 +211,12 @@ public function prefetch( $start ); } - if ($result !== false) { - $cached = $this->cacheResult($result, false); + + if ($result === false) { + return $result; } + + $cached = $this->cacheResult($result, false); if ($result instanceof PDOStatement) { $this->setCache($key, $cached, $this->memcache_prefetch); }