I'm trying to update a record using the ORM library built in to Kohana 2.3.4. I'm basically modifying the script I use to insert the record in the first place. My problem is the record is getting inserted again, not updated. Here's my script:
public function edit($id)
{
// Find the selected blog entry
$blog = ORM::factory('article')->where('id',$id)->find();
//other code to view data from $blog
// Write the changes to the db for this id
$title = $this->input->post('title');
$content = $this->input->post('text_content');
if(!empty($title) && !empty($content))
{
$edit_blog = ORM::factory('article')->where('id',$id);
$edit_blog->title = $title;
$edit_blog->content = $content;
if($edit_blog->save())
{
url::redirect('admin/dashboard/blog/manage');
}
}
I've looked over the documentation Kohana provides, but I can't find an example of updating records. I thought that the $id argument passed in to the edit method would select a record that exists already and update it, but it just inserts a new one. Any Help? thanks!