Commit b0721032 authored by Alexander Butenko's avatar Alexander Butenko

Merge pull request #259 from avbdr/master

fixes
parents 574943ce 199cdbb0
......@@ -141,13 +141,15 @@ class dbObject {
case 'hasone':
$obj = new $modelName;
$obj->returnType = $this->returnType;
return $obj->byId($this->data[$name]);
$this->data[$name] = $obj->byId($this->data[$name]);
return $this->data[$name];
break;
case 'hasmany':
$key = $this->relations[$name][2];
$obj = new $modelName;
$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;
default:
break;
......@@ -268,8 +270,12 @@ class dbObject {
* @return mixed insert id or false in case of failure
*/
public function save ($data = null) {
if ($this->isNew)
return $this->insert();
if ($this->isNew) {
$id = $this->insert();
if (isset ($this->primaryKey))
$this->data[$this->primaryKey] = $id;
return $id;
}
return $this->update($data);
}
......
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