Welcome Guest, Not a member yet? Register   Sign In
A little help with my first app...
#9

[eluser]n0xie[/eluser]
You should use the active record class.

To answer your question
Code:
//controller
function delete($id = NULL)
    {
        $this->load->model('Guestbook_model');
          $this->Guestbook_model->deleteEntry((int) $id);
        $this->load->view('delete_success');
    }

// model
function deleteEntry($id)
{
  // just to make sure we don't do anything stupid
  if ($id > 0)
  {
        $this->db->where('id',$id);
        $this->db->delete('data');
  }
}

A word of caution though. You should always do any destructive action via a POST, not via a GET request, so I would advice against doing it this way. This is to prevent numerous security issues, the most simple being, what if the Googlespider would index your site and go to the url 'example.com/guestbook/index.php/delete/2'?


Messages In This Thread
A little help with my first app... - by El Forum - 02-18-2010, 09:58 AM
A little help with my first app... - by El Forum - 02-18-2010, 10:20 AM
A little help with my first app... - by El Forum - 02-18-2010, 10:48 AM
A little help with my first app... - by El Forum - 02-18-2010, 10:51 AM
A little help with my first app... - by El Forum - 02-18-2010, 10:55 AM
A little help with my first app... - by El Forum - 02-18-2010, 11:04 AM
A little help with my first app... - by El Forum - 02-18-2010, 11:43 AM
A little help with my first app... - by El Forum - 02-20-2010, 02:14 PM
A little help with my first app... - by El Forum - 02-20-2010, 03:50 PM
A little help with my first app... - by El Forum - 02-21-2010, 12:45 AM
A little help with my first app... - by El Forum - 02-22-2010, 04:30 AM
A little help with my first app... - by El Forum - 02-22-2010, 09:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB