我想将杂货袋插入另一个crud table.can我这样做?我试过了,但它显示了两个错误,叫做
"未定义属性:Boq_doc_controller :: $ project_list_model"和 "致命错误:在null中调用成员函数show_boq_id() 第42行和第34行的C:\ xampp \ htdocs \ rcj-constructions \ back-end \ application \ controllers \ boq_doc_controller.php。
只是有顶级crud并且有一个视图boq按钮而不是编辑或删除button.once单击视图boq按钮它应该去杂货crud.i将添加我的代码。任何人都可以帮助我。 谢谢。
我的顶级crud模型
class Project_list_model extends CI_Model {
public function get_all_project(){
$this->db->select("project.project_name, project.id, client.firstname, client.lastname,staff.firstname, staff.lastname, project.location,project.category, project.start_date, project.end_date");
$this->db->from('project');
$this->db->join('client', 'project.client_id = client.client_id');
$this->db->join('staff', 'staff.id = project.staff_id');
$query = $this->db->get();
return $query->result();
}
}
我的顶级crud控制器
public function index()
{
$data['project_list'] = $this->project_list_model->get_all_project();
$this->load->view('project_list_view', $data);
}
我的顶级crud视图
<?php foreach ($project_list as $project){ ?>
<tr>
<td><?php echo $project->project_name; ?></td>
<td><?php echo $project->location; ?></td>
<td width="40" align="left" ><a href="<?php echo base_url();?>index.php/project_list/index" >view BOQ</a></td>
</tr>
<?php }?>
我的杂货店控制器
function __construct()
{
parent::__construct();
//load the Grocery_CRUD library
$this->load->library('grocery_CRUD');
$this->load->model('Project_list_model');
}
public function boq_doc(){
$crud = new grocery_CRUD();
// set datatable theme
$crud->set_theme('datatables');
//set the table name
$crud->set_table('staff');
$crud->columns('item_no','description');
$id = $this->uri->segment(3);
$data['single_boq'] = $this->project_list_model->show_boq_id($id);
//view output
$output = $crud->render();
$this->_example_output($output);
}
// edit /view /delete plan
public function boq_doc1()
{
// load plan
$this->grocery_crud->set_table('boq');
$output = $this->grocery_crud->render();
$this->_example_output($output);
}
// _example_output
function _example_output($output = null)
{
//load edit /view /delete plan
$this->load->view('our_template.php',$output);
}
// /._example_output
}