非常 Codeingiter新手,并试图实现杂货CRUD以下本教程http://www.grocerycrud.com/documentation/create-crud-codeigniter-tutorial。
在下面的代码中这样做了(顺便说一下,我正在自动加载数据库库和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);
}
**/
}
然而,当我在[BASE]/management/property加载此页面时,我得到以下错误:
Severity: Notice
Message: Undefined property: Management::$grocery_crud
Filename: controllers/management.php
Line Number: 21
有人能帮忙吗?
现在已经解决了这个问题,不是100%确定,因为我已经在我的代码和DB结构中移动了相当多,但我认为只是为了在我的DB中没有"属性"表。
物品丢失??
$crud = new Grocery_CRUD();
和设置后的数据库表
$crud->set_table('property');
为了避免用户遇到同样的问题:尝试加载带有大写'G'的grocery_crud库。换句话说,改变:
$ this ->加载>图书馆(grocery_CRUD); 之前:
$ this ->加载>图书馆(Grocery_CRUD);