【问题标题】:Codeigniter - undefined property $grocery_crudCodeigniter - 未定义的属性 $grocery_crud
【发布时间】:2014-03-24 20:36:25
【问题描述】:

非常是 Codeingiter 的新手,并尝试按照本教程 http://www.grocerycrud.com/documentation/create-crud-codeigniter-tutorial 实施 Grocery CRUD。

在下面的代码中已经这样做了(顺便说一下,我正在自动加载数据库库和 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);

}
**/
}

但是,当我在 [BASE]/management/property 加载此页面时,我收到以下错误:

Severity: Notice

Message: Undefined property: Management::$grocery_crud

Filename: controllers/management.php

Line Number: 21

有人可以帮忙吗?

【问题讨论】:

  • 尝试将库加载名称全部小写。
  • 恐怕不行,谢谢

标签: php codeigniter


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    对象丢失??

    $crud = new Grocery_CRUD();
    

    设置数据库表后

    $crud->set_table('property');
    

    【讨论】:

      【解决方案3】:

      为了让用户遇到同样的问题:尝试使用大写字母“G”加载grocery_crud 库。换句话说改变:

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

      收件人:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-06-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多