I am having fun with codeigniter but having an annoying little problem at the moment though, when trying to delete an item I get ” Message: Undefined property: Site::$url ” my only guess can be that something is not right with the url helper being included? I am autoloading it in the config.
this is my delete function in the model
function delete_record()
{
$this->db->where('id', $this->url->segment(3));
$this->db->delete('items');
}
here I am calling it in the view:
<?php echo $row->subject; ?> <?php echo anchor("site/delete/$row->id","Delete");?>
this is the controller:
function delete(){
$this->Site_model->delete_record();
$this->index();
}
and just to make sure I am not doing anything wrong.. this is in autoload in the config:
$autoload['helper'] = array('url', 'form');
$autoload['libraries'] = array('database');
Much appreciated for any help!!
There is no url class.
You want to switch
$this->url->segment(3)to$this->uri->segment(3)noting the I instead of the L.The url helper is for generating site urls, etc. The URI class is an integral part of the CI core so it is always loaded.
URI Class
URL Helper