有两个表测试和语言,当从语言表中删除代码列时,我需要从测试表中删除title_$lang
列。表格未与外键连接。它适用于插入功能。这是我的剧本:
模型:
public function deleteField($table, $id, $code){
$this->dbforge->drop_column();
if ($this->db->delete($table, array('id' => $id))&& $this->dbforge->drop_column('tests', "title_".$code)) {
$this->session->set_flashdata('success', true);
} else {
$this->session->set_flashdata('error', true);
}
return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'backend/tests';
return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'backend/languages';
}
控制器:
public function removefield($table = 0, $code)
{
if (!$table) die('!');
$id = $this->input->get('id');
redirect($this->admin_model->deleteField($table, $id, $code));
echo $code;
}
视图:
<a href="<?php echo base_url();?>backend/removefield/languages/?id=<?php echo $row['id'];?>" class="btn btn-sm btn-danger">Delete</a>
它提供 followint错误:
缺少Backend的参数2 :: removefield()文件名:controllers / Backend.php
未定义的变量:代码文件名:controllers / Backend.php
未定义属性:Backend :: $ dbforge文件名:core / Model.php
在null上调用成员函数drop_column()文件名:models / Admin_model.php