-1

我对 PHP 和 CodeIgniter 完全陌生,我正在尝试在视图中创建一个链接,单击该链接将返回来自特定类别的数据列表。

vgs_model.php 模型

public function pcList(){

    $this->db->select('*');
    $this->db->from('videogame');
    $this->db->where('Format', 'PC');
    $query = $this->db->get();

    return $query->result();

}

search.php 控制器

public function __construct()
{
    parent::__construct();

    $this->load->helper('form');
    $this->load->helper('url');      
    $this->load->model('vgs_model');

}

public function index()
{
    $this->load->view('header_view');
    $this->load->view('search_view');
    $this->load->view('footer_view');
}

public function getPc(){

    $search_term = 'PC';

    $data['results'] = $this->Vgs_model->pcList();
    $this->load->view('search_results', $data);

}

search_view 查看

<a href = <?php echo site_url('Hello/getPc'); ?>>View PC Games</a>

我一直收到以下错误

Message: Undefined property: Search::$Vgs_model

Filename: controllers/search.php

Line Number: 40

第40行是这个 $data['results'] = $this->Vgs_model->pcList();

我究竟做错了什么?任何帮助,将不胜感激。

感谢您阅读我的帖子。

4

1 回答 1

1

那应该是小写的:

 $data['results'] = $this->vgs_model->pcList();
于 2013-05-03T01:59:58.450 回答