Commit 199cdbb0 authored by Alexander Butenko's avatar Alexander Butenko

Cache relations results

parent 9013d6ec
...@@ -141,13 +141,15 @@ class dbObject { ...@@ -141,13 +141,15 @@ class dbObject {
case 'hasone': case 'hasone':
$obj = new $modelName; $obj = new $modelName;
$obj->returnType = $this->returnType; $obj->returnType = $this->returnType;
return $obj->byId($this->data[$name]); $this->data[$name] = $obj->byId($this->data[$name]);
return $this->data[$name];
break; break;
case 'hasmany': case 'hasmany':
$key = $this->relations[$name][2]; $key = $this->relations[$name][2];
$obj = new $modelName; $obj = new $modelName;
$obj->returnType = $this->returnType; $obj->returnType = $this->returnType;
return $obj->where($key, $this->data[$this->primaryKey])->get(); $this->data[$name] = $obj->where($key, $this->data[$this->primaryKey])->get();
return $this->data[$name];
break; break;
default: default:
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment