Remove insert and update methods from Eloquent.

This commit is contained in:
Taylor Otwell 2011-07-08 07:13:30 -07:00
parent 666ebf2119
commit 21efdbf69b
1 changed files with 11 additions and 24 deletions

View File

@ -303,35 +303,22 @@ public function save()
$this->timestamp();
}
$result = ($this->exists) ? $this->update() : $this->insert();
if ($this->exists)
{
$result = $this->query->where('id', '=', $this->attributes['id'])->update($this->dirty) == 1;
}
else
{
$this->attributes['id'] = $this->query->insert_get_id($this->attributes);
$result = $this->exists = is_numeric($this->id);
}
$this->dirty = array();
return $result;
}
/**
* Update an existing model in the database.
*
* @return bool
*/
private function update()
{
return $this->query->where('id', '=', $this->attributes['id'])->update($this->dirty) == 1;
}
/**
* Insert a new model into the database.
*
* @return bool
*/
private function insert()
{
$this->attributes['id'] = $this->query->insert_get_id($this->attributes);
return $this->exists = is_numeric($this->id);
}
/**
* Delete a model from the database.
*
@ -345,7 +332,7 @@ public function delete($id = null)
return Query::table(static::table(get_class($this)))->delete($this->id);
}
return 0;
return $this->query->delete();
}
/**