简体   繁体   English

Codeigniter-未定义的属性$ grocery_crud

[英]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 . 对Codeingiter来说是非常新的知识,并尝试按照本教程http://www.grocerycrud.com/documentation/create-crud-codeigniter-tutorial实施Grocery CRUD。

Have done so in the following code (by the way, I'm autoloading database library and url helper). 在以下代码中完成了此操作(顺便说一句,我正在自动加载数据库库和url帮助器)。

<?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: 但是,当我在[BASE] / management / property加载此页面时,出现以下错误:

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'. 为了使用户遇到相同的问题,请执行以下操作:尝试将大写的'G'装入杂货库。 In other words change: 换句话说,更改:

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

To: 至:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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