Reputation: 309
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!!
Upvotes: 2
Views: 778
Reputation: 4951
What you done is all right just replace the 'url' to 'uri',like this.
$this->url->segment(3) to $this->uri->segment(3) //replace url to uri.
Upvotes: 0
Reputation: 28753
There are two changes u hav to made:
FIRST:
$this->url->segment(3) to $this->uri->segment(3);
SECOND:In the view
<?php echo $row->subject; ?> <?php echo anchor("site/delete/".$row->id,"Delete");?>
Upvotes: 0
Reputation: 418
It must be
$this->uri->segment(3) not $this->url->segment(3)
Upvotes: 0
Reputation: 4565
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.
Upvotes: 1