简体   繁体   中英

Codeigniter - undefined property $grocery_crud

Very new to Codeingiter and trying to implement Grocery CRUD following this tutorial http://www.grocerycrud.com/documentation/create-crud-codeigniter-tutorial .

Have done so in the following code (by the way, I'm autoloading database library and url helper).

<?php

class Management extends CI_Controller {


public function construct()
{
    parent::__construct();
    $this->load->library('grocery_CRUD');
}

public function index ()
{
    echo "<h1>Just work!</h1>";
    die();
}


public function property ()
{
    $this->grocery_crud->set_table('property');
    $output = $this->grocery_crud->render();


    echo "<pre>";
    print_r($output);
    echo "</pre>";
    die();
}


/**
public function view($page = 'management_page')
{
    if ( ! file_exists('application/views/pages/'.$page.'.php'))
    {
        // Whoops, we don't have a page for that!
        show_404();
    }



    $data['title'] = ucfirst($page); // Capitalize the first letter



    $this->load->view('templates/header', $data);               
    $this->load->view('pages/'.$page, $data);
    $this->load->view('templates/footer', $data);

}
**/
}

However, when I load this page at [BASE ]/management/property I get the following error:

Severity: Notice

Message: Undefined property: Management::$grocery_crud

Filename: controllers/management.php

Line Number: 21

Can anyone help?

现在已经解决了这个问题,由于我已经在代码和数据库结构中进行了相当多的改进,因此不能100%地确定,但是我认为这与数据库中没有“属性”表有关。

Object missing ??

$crud = new Grocery_CRUD();

and after set the database table

$crud->set_table('property');

For the sake of users encountering the same issue: Try loading the grocery_crud library with a caps 'G'. In other words change:

$this->load->library('grocery_CRUD');

To:

$this->load->library('Grocery_CRUD');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM