我有一个表名tbl_campaign_detail,其中blogger_ID和campaign_ID被添加为外键以及其他一些字段。。
我想从这个表中删除记录。。当我执行删除时,它删除了记录,但也给出了一个错误,
错误:
类型:ArgumentCountError
消息:Campaign::camp_detls((函数的参数太少,在第532行的D:\XAMPP\htdocs\bms\system\core\CodeIgniter.php中传递了0,而预期的正好为1
文件名:D:\XAMPP\htdocs\bms\application\controllers\Campaign.php
行号:35
它工作得很好,但也显示了这个错误。。。
这是我的型号:
public function camp_detl_delete($did){
$this->db->where('detail_id', $did);
$this->db->delete('tbl_campaign_detail');
if($this->db->affected_rows() > 0){
return true;
}else{
return false;
}
}
控制器:
public function camp_detl_delete($id){
$result = $this->cm->camp_detl_delete($id);
if($result){
$this->session->set_flashdata('success_msg', 'Record deleted successfully');
}else{
$this->session->set_flashdata('error_msg', 'Faill to delete record');
}
redirect(base_url('campaign/camp_detls/')); //this should be directed to particular id of camp_detls
}
和视图:
$did = $cmp->detail_id;
<a href="<?php echo base_url('campaign/camp_detl_delete/' .$did); ?>" onclick="return confirm('Do you want to delete this record?');">
<span class="glyphicon glyphicon-trash"></span>
</a>
但它显示控制器线路35中提到的错误的地方是:
function camp_detls($id){
$data['camps'] = $this->cm->camp_detailByID($id);
$data['campaign'] = $this->cm->getCampaignsById($id);
$data['blogger'] = $this->cm->getAllBloggers();
$data['cat'] = $this->cm->getAllCategory();
$this->load->view('layout/header');
$this->load->view('campaign/campaign_detail', $data);
$this->load->view('layout/footer');
}
请帮忙,我该如何删除此错误?我只是想简单地删除它。
消息:参数太少,无法运行Campaign::camp_detls((,0通过(…(
此错误意味着,对于您定义并要求$id
作为参数的函数(camp_detls()
(,没有传递任何信息。
我想问题就在这条线上:
redirect(base_url('campaign/camp_detls/')); //this should be directed to particular id of camp_detls
正如评论所暗示的那样,但你看。在这里,您希望重定向到特定的camp_detls
,但没有提供$id
。