Commit 21efdbf6 authored by Taylor Otwell's avatar Taylor Otwell

Remove insert and update methods from Eloquent.

parent 666ebf21
...@@ -303,35 +303,22 @@ abstract class Eloquent { ...@@ -303,35 +303,22 @@ abstract class Eloquent {
$this->timestamp(); $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(); $this->dirty = array();
return $result; 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. * Delete a model from the database.
* *
...@@ -345,7 +332,7 @@ abstract class Eloquent { ...@@ -345,7 +332,7 @@ abstract class Eloquent {
return Query::table(static::table(get_class($this)))->delete($this->id); return Query::table(static::table(get_class($this)))->delete($this->id);
} }
return 0; return $this->query->delete();
} }
/** /**
......
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