Skip to content

Commit 199cdbb

Browse files
committed
Cache relations results
1 parent 9013d6e commit 199cdbb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dbObject.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,15 @@ public function __get ($name) {
141141
case 'hasone':
142142
$obj = new $modelName;
143143
$obj->returnType = $this->returnType;
144-
return $obj->byId($this->data[$name]);
144+
$this->data[$name] = $obj->byId($this->data[$name]);
145+
return $this->data[$name];
145146
break;
146147
case 'hasmany':
147148
$key = $this->relations[$name][2];
148149
$obj = new $modelName;
149150
$obj->returnType = $this->returnType;
150-
return $obj->where($key, $this->data[$this->primaryKey])->get();
151+
$this->data[$name] = $obj->where($key, $this->data[$this->primaryKey])->get();
152+
return $this->data[$name];
151153
break;
152154
default:
153155
break;

0 commit comments

Comments
 (0)