我在此代码中出现“致命错误:无法访问1540行/Applications/XAMPP/xamppfiles/htdocs/cityland/application/libraries/Grocery_CRUD.php中的空属性”错误
public function projectAmenities()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('tbl_sys_project_amenity');
$crud->set_relation('amenity','tbl_sys_amenities','amenity');
$crud->set_relation('project_id','tbl_sys_projects','project_id');
$crud->set_subject('Amenities');
$output = $crud->render();
$this->projectAmenitiesOutput($output);
}
tbl_sys_project_amenity是tbl_sys_amenities和tbl_sys_projects的联合实体。此错误仅显示在此特定表中。
我的表结构
tbl_sys_amenities
amenity
description
tbl_sys_projects
project_id
title
location
tbl_sys_project_amenity
project_id
amenity
quantity
答案 0 :(得分:6)
您需要在表格id
上创建primary key
列autoincrement
和tbl_sys_project_amenity
,它将会修复。
答案 1 :(得分:0)
使用缓存数据库时 替换配置数据库
$ db ['default'] ['cache_on'] = TRUE; $ db ['default'] ['cachedir'] = APPPATH。 '缓存';
到
$ db ['default'] ['cache_on'] = false; $ db ['default'] ['cachedir'] ='';