@@ -24,7 +24,7 @@  | 
                                                    ||
| 24 | 24 | }  | 
                                                        
| 25 | 25 | |
| 26 | 26 |  	public function getCacheMode() { | 
                                                        
| 27 | - return (int) ($this->options['cachemode'] ?? 0);  | 
                                                        |
| 27 | + return (int)($this->options['cachemode'] ?? 0);  | 
                                                        |
| 28 | 28 | }  | 
                                                        
| 29 | 29 | |
| 30 | 30 |  	public function read($option) { | 
                                                        
@@ -2,37 +2,37 @@ discard block  | 
                                                    ||
| 2 | 2 | namespace Maphper\DataSource;  | 
                                                        
| 3 | 3 | |
| 4 | 4 |  class DatabaseSelect { | 
                                                        
| 5 | - private $resultCache = [];  | 
                                                        |
| 6 | - private $idCache = [];  | 
                                                        |
| 7 | - private $idCacheTime = [];  | 
                                                        |
| 8 | - private $selectBuilder;  | 
                                                        |
| 9 | - private $whereBuilder;  | 
                                                        |
| 10 | - private $adapter;  | 
                                                        |
| 11 | - private $databaseModify;  | 
                                                        |
| 12 | - private $defaultSort;  | 
                                                        |
| 13 | - private $table;  | 
                                                        |
| 14 | -  | 
                                                        |
| 15 | -    public function __construct(DatabaseAdapter $adapter, DatabaseModify $databaseModify, $table, $defaultSort, $cacheMode) { | 
                                                        |
| 16 | - $this->adapter = $adapter;  | 
                                                        |
| 17 | - $this->databaseModify = $databaseModify;  | 
                                                        |
| 18 | - $this->selectBuilder = new \Maphper\Lib\SelectBuilder();  | 
                                                        |
| 19 | - $this->whereBuilder = new \Maphper\Lib\Sql\WhereBuilder();  | 
                                                        |
| 20 | - $this->defaultSort = $defaultSort;  | 
                                                        |
| 21 | - $this->cacheMode = $cacheMode;  | 
                                                        |
| 22 | - $this->table = $table;  | 
                                                        |
| 23 | - }  | 
                                                        |
| 24 | -  | 
                                                        |
| 25 | -    private function cacheUpdateRequired($id) { | 
                                                        |
| 26 | -      if ($this->cacheMode > 0) { | 
                                                        |
| 27 | - if (!isset($this->idCacheTime[$id])) return true; // Cache time has not been set for first time  | 
                                                        |
| 28 | -  | 
                                                        |
| 29 | - if (time() - $this->idCacheTime[$id] > $this->cacheMode) return true; // Cache time has expired  | 
                                                        |
| 30 | - }  | 
                                                        |
| 31 | -  | 
                                                        |
| 32 | - if (!isset($this->idCache[$id])) return true; // Cache has not been set for first time  | 
                                                        |
| 33 | -  | 
                                                        |
| 34 | - return false;  | 
                                                        |
| 35 | - }  | 
                                                        |
| 5 | + private $resultCache = [];  | 
                                                        |
| 6 | + private $idCache = [];  | 
                                                        |
| 7 | + private $idCacheTime = [];  | 
                                                        |
| 8 | + private $selectBuilder;  | 
                                                        |
| 9 | + private $whereBuilder;  | 
                                                        |
| 10 | + private $adapter;  | 
                                                        |
| 11 | + private $databaseModify;  | 
                                                        |
| 12 | + private $defaultSort;  | 
                                                        |
| 13 | + private $table;  | 
                                                        |
| 14 | +  | 
                                                        |
| 15 | +	public function __construct(DatabaseAdapter $adapter, DatabaseModify $databaseModify, $table, $defaultSort, $cacheMode) { | 
                                                        |
| 16 | + $this->adapter = $adapter;  | 
                                                        |
| 17 | + $this->databaseModify = $databaseModify;  | 
                                                        |
| 18 | + $this->selectBuilder = new \Maphper\Lib\SelectBuilder();  | 
                                                        |
| 19 | + $this->whereBuilder = new \Maphper\Lib\Sql\WhereBuilder();  | 
                                                        |
| 20 | + $this->defaultSort = $defaultSort;  | 
                                                        |
| 21 | + $this->cacheMode = $cacheMode;  | 
                                                        |
| 22 | + $this->table = $table;  | 
                                                        |
| 23 | + }  | 
                                                        |
| 24 | +  | 
                                                        |
| 25 | +	private function cacheUpdateRequired($id) { | 
                                                        |
| 26 | +	  if ($this->cacheMode > 0) { | 
                                                        |
| 27 | + if (!isset($this->idCacheTime[$id])) return true; // Cache time has not been set for first time  | 
                                                        |
| 28 | +  | 
                                                        |
| 29 | + if (time() - $this->idCacheTime[$id] > $this->cacheMode) return true; // Cache time has expired  | 
                                                        |
| 30 | + }  | 
                                                        |
| 31 | +  | 
                                                        |
| 32 | + if (!isset($this->idCache[$id])) return true; // Cache has not been set for first time  | 
                                                        |
| 33 | +  | 
                                                        |
| 34 | + return false;  | 
                                                        |
| 35 | + }  | 
                                                        |
| 36 | 36 | |
| 37 | 37 |    public function findById($id, $pk) { | 
                                                        
| 38 | 38 |  		if ($this->cacheMode < 0 || $this->cacheUpdateRequired($id)) { | 
                                                        
@@ -40,19 +40,19 @@ discard block  | 
                                                    ||
| 40 | 40 | $result = $this->selectQuery($this->selectBuilder->select($this->table, $pk . ' = :id', [':id' => $id], ['limit' => 1]));  | 
                                                        
| 41 | 41 | }  | 
                                                        
| 42 | 42 |  			catch (\Exception $e) { | 
                                                        
| 43 | - // Don't issue an error if it cannot be found since we return null  | 
                                                        |
| 43 | + // Don't issue an error if it cannot be found since we return null  | 
                                                        |
| 44 | 44 | }  | 
                                                        
| 45 | 45 | |
| 46 | 46 | if (isset($result[0])) $result = $result[0];  | 
                                                        
| 47 | 47 | else return null;  | 
                                                        
| 48 | 48 | }  | 
                                                        
| 49 | 49 | |
| 50 | - if ($this->cacheMode < 0) return $result; // Cache mode is off  | 
                                                        |
| 50 | + if ($this->cacheMode < 0) return $result; // Cache mode is off  | 
                                                        |
| 51 | 51 | |
| 52 | -    if ($this->cacheUpdateRequired()) { | 
                                                        |
| 53 | - $this->idCache[$id] = $result;  | 
                                                        |
| 54 | - $this->idCacheTime[$id] = time();  | 
                                                        |
| 55 | - }  | 
                                                        |
| 52 | +	if ($this->cacheUpdateRequired()) { | 
                                                        |
| 53 | + $this->idCache[$id] = $result;  | 
                                                        |
| 54 | + $this->idCacheTime[$id] = time();  | 
                                                        |
| 55 | + }  | 
                                                        |
| 56 | 56 | |
| 57 | 57 | return $this->idCache[$id];  | 
                                                        
| 58 | 58 | }  | 
                                                        
@@ -60,7 +60,7 @@ discard block  | 
                                                    ||
| 60 | 60 |    public function findByField(array $fields, $options = []) { | 
                                                        
| 61 | 61 | $cacheId = md5(serialize(func_get_args()));  | 
                                                        
| 62 | 62 | |
| 63 | -    if ($this->cacheMode < 0 || $this->cacheUpdateRequired($cacheId)) { | 
                                                        |
| 63 | +	if ($this->cacheMode < 0 || $this->cacheUpdateRequired($cacheId)) { | 
                                                        |
| 64 | 64 | $query = $this->whereBuilder->createSql($fields);  | 
                                                        
| 65 | 65 | |
| 66 | 66 | if (!isset($options['order'])) $options['order'] = $this->defaultSort;  | 
                                                        
@@ -76,17 +76,17 @@ discard block  | 
                                                    ||
| 76 | 76 | }  | 
                                                        
| 77 | 77 | }  | 
                                                        
| 78 | 78 | |
| 79 | - if ($this->cacheMode < 0) return $result; // Cache mode is off  | 
                                                        |
| 79 | + if ($this->cacheMode < 0) return $result; // Cache mode is off  | 
                                                        |
| 80 | 80 | |
| 81 | -    if ($this->cacheUpdateRequired($cacheId)) { | 
                                                        |
| 82 | - $this->idCache[$cacheId] = $result;  | 
                                                        |
| 83 | - $this->idCacheTime[$cacheId] = time();  | 
                                                        |
| 84 | - }  | 
                                                        |
| 81 | +	if ($this->cacheUpdateRequired($cacheId)) { | 
                                                        |
| 82 | + $this->idCache[$cacheId] = $result;  | 
                                                        |
| 83 | + $this->idCacheTime[$cacheId] = time();  | 
                                                        |
| 84 | + }  | 
                                                        |
| 85 | 85 | |
| 86 | 86 | return $this->idCache[$cacheId];  | 
                                                        
| 87 | 87 | }  | 
                                                        
| 88 | 88 | |
| 89 | -    public function findAggregate($function, $field, $group = null, array $criteria = [], array $options = []) { | 
                                                        |
| 89 | +	public function findAggregate($function, $field, $group = null, array $criteria = [], array $options = []) { | 
                                                        |
| 90 | 90 | //Cannot count/sum/max multiple fields, pick the first one. This should only come into play when trying to count() a mapper with multiple primary keys  | 
                                                        
| 91 | 91 | if (is_array($field)) $field = $field[0];  | 
                                                        
| 92 | 92 | $query = $this->whereBuilder->createSql($criteria);  | 
                                                        
@@ -103,39 +103,39 @@ discard block  | 
                                                    ||
| 103 | 103 | }  | 
                                                        
| 104 | 104 | }  | 
                                                        
| 105 | 105 | |
| 106 | -    private function determineAggregateResult($result, $group, $field) { | 
                                                        |
| 107 | -        if ($group != null) { | 
                                                        |
| 108 | - $ret = [];  | 
                                                        |
| 109 | - foreach ($result as $res) $ret[$res->$field] = $res->val;  | 
                                                        |
| 110 | - return $ret;  | 
                                                        |
| 111 | - }  | 
                                                        |
| 112 | - else if (isset($result[0])) return $result[0]->val;  | 
                                                        |
| 113 | - else return 0;  | 
                                                        |
| 114 | - }  | 
                                                        |
| 115 | -  | 
                                                        |
| 116 | -    private function selectQuery(\Maphper\Lib\Query $query) { | 
                                                        |
| 117 | - return $this->adapter->query($query)->fetchAll(\PDO::FETCH_OBJ);  | 
                                                        |
| 118 | - }  | 
                                                        |
| 119 | -  | 
                                                        |
| 120 | -    public function clearResultCache() { | 
                                                        |
| 121 | - if ($this->cacheMode >= 0) $this->resultCache = [];  | 
                                                        |
| 122 | - }  | 
                                                        |
| 123 | -  | 
                                                        |
| 124 | -    public function clearIDCache() { | 
                                                        |
| 125 | - if ($this->cacheMode >= 0) $this->idCache = [];  | 
                                                        |
| 126 | - }  | 
                                                        |
| 127 | -  | 
                                                        |
| 128 | -    public function updateCache($data, $pkValue) { | 
                                                        |
| 129 | -        if ($this->cacheMode >= 0) { | 
                                                        |
| 130 | - if (isset($this->cache[$pkValue])) $this->cache[$pkValue] = (object) array_merge((array)$this->cache[$pkValue], (array)$data);  | 
                                                        |
| 131 | - else $this->cache[$pkValue] = $data;  | 
                                                        |
| 132 | - }  | 
                                                        |
| 133 | - }  | 
                                                        |
| 134 | -  | 
                                                        |
| 135 | -    public function deleteIDFromCache($id) { | 
                                                        |
| 136 | -        if ($this->cacheMode >= 0) { | 
                                                        |
| 137 | - unset($this->idCache[$id]);  | 
                                                        |
| 138 | - unset($this->idCacheTime[$id]);  | 
                                                        |
| 139 | - }  | 
                                                        |
| 140 | - }  | 
                                                        |
| 106 | +	private function determineAggregateResult($result, $group, $field) { | 
                                                        |
| 107 | +		if ($group != null) { | 
                                                        |
| 108 | + $ret = [];  | 
                                                        |
| 109 | + foreach ($result as $res) $ret[$res->$field] = $res->val;  | 
                                                        |
| 110 | + return $ret;  | 
                                                        |
| 111 | + }  | 
                                                        |
| 112 | + else if (isset($result[0])) return $result[0]->val;  | 
                                                        |
| 113 | + else return 0;  | 
                                                        |
| 114 | + }  | 
                                                        |
| 115 | +  | 
                                                        |
| 116 | +	private function selectQuery(\Maphper\Lib\Query $query) { | 
                                                        |
| 117 | + return $this->adapter->query($query)->fetchAll(\PDO::FETCH_OBJ);  | 
                                                        |
| 118 | + }  | 
                                                        |
| 119 | +  | 
                                                        |
| 120 | +	public function clearResultCache() { | 
                                                        |
| 121 | + if ($this->cacheMode >= 0) $this->resultCache = [];  | 
                                                        |
| 122 | + }  | 
                                                        |
| 123 | +  | 
                                                        |
| 124 | +	public function clearIDCache() { | 
                                                        |
| 125 | + if ($this->cacheMode >= 0) $this->idCache = [];  | 
                                                        |
| 126 | + }  | 
                                                        |
| 127 | +  | 
                                                        |
| 128 | +	public function updateCache($data, $pkValue) { | 
                                                        |
| 129 | +		if ($this->cacheMode >= 0) { | 
                                                        |
| 130 | + if (isset($this->cache[$pkValue])) $this->cache[$pkValue] = (object) array_merge((array)$this->cache[$pkValue], (array)$data);  | 
                                                        |
| 131 | + else $this->cache[$pkValue] = $data;  | 
                                                        |
| 132 | + }  | 
                                                        |
| 133 | + }  | 
                                                        |
| 134 | +  | 
                                                        |
| 135 | +	public function deleteIDFromCache($id) { | 
                                                        |
| 136 | +		if ($this->cacheMode >= 0) { | 
                                                        |
| 137 | + unset($this->idCache[$id]);  | 
                                                        |
| 138 | + unset($this->idCacheTime[$id]);  | 
                                                        |
| 139 | + }  | 
                                                        |
| 140 | + }  | 
                                                        |
| 141 | 141 | }  | 
                                                        
@@ -127,7 +127,7 @@  | 
                                                    ||
| 127 | 127 | |
| 128 | 128 |      public function updateCache($data, $pkValue) { | 
                                                        
| 129 | 129 |          if ($this->cacheMode >= 0) { | 
                                                        
| 130 | - if (isset($this->cache[$pkValue])) $this->cache[$pkValue] = (object) array_merge((array)$this->cache[$pkValue], (array)$data);  | 
                                                        |
| 130 | + if (isset($this->cache[$pkValue])) $this->cache[$pkValue] = (object)array_merge((array)$this->cache[$pkValue], (array)$data);  | 
                                                        |
| 131 | 131 | else $this->cache[$pkValue] = $data;  | 
                                                        
| 132 | 132 | }  | 
                                                        
| 133 | 133 | }  | 
                                                        
@@ -24,12 +24,21 @@ discard block  | 
                                                    ||
| 24 | 24 | |
| 25 | 25 |      private function cacheUpdateRequired($id) { | 
                                                        
| 26 | 26 |        if ($this->cacheMode > 0) { | 
                                                        
| 27 | - if (!isset($this->idCacheTime[$id])) return true; // Cache time has not been set for first time  | 
                                                        |
| 27 | +        if (!isset($this->idCacheTime[$id])) { | 
                                                        |
| 28 | + return true;  | 
                                                        |
| 29 | + }  | 
                                                        |
| 30 | + // Cache time has not been set for first time  | 
                                                        |
| 28 | 31 | |
| 29 | - if (time() - $this->idCacheTime[$id] > $this->cacheMode) return true; // Cache time has expired  | 
                                                        |
| 32 | +        if (time() - $this->idCacheTime[$id] > $this->cacheMode) { | 
                                                        |
| 33 | + return true;  | 
                                                        |
| 34 | + }  | 
                                                        |
| 35 | + // Cache time has expired  | 
                                                        |
| 30 | 36 | }  | 
                                                        
| 31 | 37 | |
| 32 | - if (!isset($this->idCache[$id])) return true; // Cache has not been set for first time  | 
                                                        |
| 38 | +      if (!isset($this->idCache[$id])) { | 
                                                        |
| 39 | + return true;  | 
                                                        |
| 40 | + }  | 
                                                        |
| 41 | + // Cache has not been set for first time  | 
                                                        |
| 33 | 42 | |
| 34 | 43 | return false;  | 
                                                        
| 35 | 44 | }  | 
                                                        
@@ -38,16 +47,21 @@ discard block  | 
                                                    ||
| 38 | 47 |  		if ($this->cacheMode < 0 || $this->cacheUpdateRequired($id)) { | 
                                                        
| 39 | 48 |  			try { | 
                                                        
| 40 | 49 | $result = $this->selectQuery($this->selectBuilder->select($this->table, $pk . ' = :id', [':id' => $id], ['limit' => 1]));  | 
                                                        
| 41 | - }  | 
                                                        |
| 42 | -			catch (\Exception $e) { | 
                                                        |
| 50 | +			} catch (\Exception $e) { | 
                                                        |
| 43 | 51 | // Don't issue an error if it cannot be found since we return null  | 
                                                        
| 44 | 52 | }  | 
                                                        
| 45 | 53 | |
| 46 | - if (isset($result[0])) $result = $result[0];  | 
                                                        |
| 47 | - else return null;  | 
                                                        |
| 54 | +			if (isset($result[0])) { | 
                                                        |
| 55 | + $result = $result[0];  | 
                                                        |
| 56 | +			} else { | 
                                                        |
| 57 | + return null;  | 
                                                        |
| 58 | + }  | 
                                                        |
| 48 | 59 | }  | 
                                                        
| 49 | 60 | |
| 50 | - if ($this->cacheMode < 0) return $result; // Cache mode is off  | 
                                                        |
| 61 | +    if ($this->cacheMode < 0) { | 
                                                        |
| 62 | + return $result;  | 
                                                        |
| 63 | + }  | 
                                                        |
| 64 | + // Cache mode is off  | 
                                                        |
| 51 | 65 | |
| 52 | 66 |      if ($this->cacheUpdateRequired()) { | 
                                                        
| 53 | 67 | $this->idCache[$id] = $result;  | 
                                                        
@@ -63,20 +77,24 @@ discard block  | 
                                                    ||
| 63 | 77 |      if ($this->cacheMode < 0 || $this->cacheUpdateRequired($cacheId)) { | 
                                                        
| 64 | 78 | $query = $this->whereBuilder->createSql($fields);  | 
                                                        
| 65 | 79 | |
| 66 | - if (!isset($options['order'])) $options['order'] = $this->defaultSort;  | 
                                                        |
| 80 | +			if (!isset($options['order'])) { | 
                                                        |
| 81 | + $options['order'] = $this->defaultSort;  | 
                                                        |
| 82 | + }  | 
                                                        |
| 67 | 83 | |
| 68 | 84 |  			try { | 
                                                        
| 69 | 85 | $result = $this->selectQuery($this->selectBuilder->select($this->table, $query['sql'], $query['args'], $options));  | 
                                                        
| 70 | 86 | $this->databaseModify->addIndex(array_keys($query['args']));  | 
                                                        
| 71 | 87 |  				$this->databaseModify->addIndex(explode(',', $options['order'])); | 
                                                        
| 72 | - }  | 
                                                        |
| 73 | -			catch (\Exception $e) { | 
                                                        |
| 88 | +			} catch (\Exception $e) { | 
                                                        |
| 74 | 89 | $this->errors[] = $e;  | 
                                                        
| 75 | 90 | $result = [];  | 
                                                        
| 76 | 91 | }  | 
                                                        
| 77 | 92 | }  | 
                                                        
| 78 | 93 | |
| 79 | - if ($this->cacheMode < 0) return $result; // Cache mode is off  | 
                                                        |
| 94 | +    if ($this->cacheMode < 0) { | 
                                                        |
| 95 | + return $result;  | 
                                                        |
| 96 | + }  | 
                                                        |
| 97 | + // Cache mode is off  | 
                                                        |
| 80 | 98 | |
| 81 | 99 |      if ($this->cacheUpdateRequired($cacheId)) { | 
                                                        
| 82 | 100 | $this->idCache[$cacheId] = $result;  | 
                                                        
@@ -88,7 +106,9 @@ discard block  | 
                                                    ||
| 88 | 106 | |
| 89 | 107 |      public function findAggregate($function, $field, $group = null, array $criteria = [], array $options = []) { | 
                                                        
| 90 | 108 | //Cannot count/sum/max multiple fields, pick the first one. This should only come into play when trying to count() a mapper with multiple primary keys  | 
                                                        
| 91 | - if (is_array($field)) $field = $field[0];  | 
                                                        |
| 109 | +		if (is_array($field)) { | 
                                                        |
| 110 | + $field = $field[0];  | 
                                                        |
| 111 | + }  | 
                                                        |
| 92 | 112 | $query = $this->whereBuilder->createSql($criteria);  | 
                                                        
| 93 | 113 | |
| 94 | 114 |  		try { | 
                                                        
@@ -97,8 +117,7 @@ discard block  | 
                                                    ||
| 97 | 117 | $result = $this->selectQuery($this->selectBuilder->aggregate($this->table, $function, $field, $query['sql'], $query['args'], $group));  | 
                                                        
| 98 | 118 | |
| 99 | 119 | return $this->determineAggregateResult($result, $group, $field);  | 
                                                        
| 100 | - }  | 
                                                        |
| 101 | -		catch (\Exception $e) { | 
                                                        |
| 120 | +		} catch (\Exception $e) { | 
                                                        |
| 102 | 121 | return $group ? [] : 0;  | 
                                                        
| 103 | 122 | }  | 
                                                        
| 104 | 123 | }  | 
                                                        
@@ -106,11 +125,15 @@ discard block  | 
                                                    ||
| 106 | 125 |      private function determineAggregateResult($result, $group, $field) { | 
                                                        
| 107 | 126 |          if ($group != null) { | 
                                                        
| 108 | 127 | $ret = [];  | 
                                                        
| 109 | - foreach ($result as $res) $ret[$res->$field] = $res->val;  | 
                                                        |
| 128 | +            foreach ($result as $res) { | 
                                                        |
| 129 | + $ret[$res->$field] = $res->val;  | 
                                                        |
| 130 | + }  | 
                                                        |
| 110 | 131 | return $ret;  | 
                                                        
| 132 | +        } else if (isset($result[0])) { | 
                                                        |
| 133 | + return $result[0]->val;  | 
                                                        |
| 134 | +        } else { | 
                                                        |
| 135 | + return 0;  | 
                                                        |
| 111 | 136 | }  | 
                                                        
| 112 | - else if (isset($result[0])) return $result[0]->val;  | 
                                                        |
| 113 | - else return 0;  | 
                                                        |
| 114 | 137 | }  | 
                                                        
| 115 | 138 | |
| 116 | 139 |      private function selectQuery(\Maphper\Lib\Query $query) { | 
                                                        
@@ -118,17 +141,24 @@ discard block  | 
                                                    ||
| 118 | 141 | }  | 
                                                        
| 119 | 142 | |
| 120 | 143 |      public function clearResultCache() { | 
                                                        
| 121 | - if ($this->cacheMode >= 0) $this->resultCache = [];  | 
                                                        |
| 144 | +        if ($this->cacheMode >= 0) { | 
                                                        |
| 145 | + $this->resultCache = [];  | 
                                                        |
| 146 | + }  | 
                                                        |
| 122 | 147 | }  | 
                                                        
| 123 | 148 | |
| 124 | 149 |      public function clearIDCache() { | 
                                                        
| 125 | - if ($this->cacheMode >= 0) $this->idCache = [];  | 
                                                        |
| 150 | +        if ($this->cacheMode >= 0) { | 
                                                        |
| 151 | + $this->idCache = [];  | 
                                                        |
| 152 | + }  | 
                                                        |
| 126 | 153 | }  | 
                                                        
| 127 | 154 | |
| 128 | 155 |      public function updateCache($data, $pkValue) { | 
                                                        
| 129 | 156 |          if ($this->cacheMode >= 0) { | 
                                                        
| 130 | - if (isset($this->cache[$pkValue])) $this->cache[$pkValue] = (object) array_merge((array)$this->cache[$pkValue], (array)$data);  | 
                                                        |
| 131 | - else $this->cache[$pkValue] = $data;  | 
                                                        |
| 157 | +  		    if (isset($this->cache[$pkValue])) { | 
                                                        |
| 158 | + $this->cache[$pkValue] = (object) array_merge((array)$this->cache[$pkValue], (array)$data);  | 
                                                        |
| 159 | +  		    } else { | 
                                                        |
| 160 | + $this->cache[$pkValue] = $data;  | 
                                                        |
| 161 | + }  | 
                                                        |
| 132 | 162 | }  | 
                                                        
| 133 | 163 | }  | 
                                                        
| 134 | 164 | |