Katherine
Katherine

Reputation: 573

Codeigniter and Grocery CRUD - Fatal error: Cannot access empty property

I get the "Fatal error: Cannot access empty property in /Applications/XAMPP/xamppfiles/htdocs/cityland/application/libraries/Grocery_CRUD.php on line 1540" error in this code

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 is an accociative entity of tbl_sys_amenities and tbl_sys_projects. This error only shows up in this specific table.

My table structure

tbl_sys_amenities

amenity
description

tbl_sys_projects

project_id
title
location

tbl_sys_project_amenity

project_id
amenity
quantity

Upvotes: 2

Views: 3216

Answers (2)

rado razafindraibe
rado razafindraibe

Reputation: 1

when you use cache database replace config database

$db['default']['cache_on'] = TRUE; $db['default']['cachedir'] = APPPATH . 'cache';

to

$db['default']['cache_on'] = false; $db['default']['cachedir'] = '';

Upvotes: 0

Erman Belegu
Erman Belegu

Reputation: 4079

You need to create the id column as primary key and autoincrement on the table tbl_sys_project_amenity and it will fix.

Upvotes: 6

Related Questions