CodeIgniter链接搜索

时间:2013-05-03 01:55:37

标签: php codeigniter

我是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();

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

感谢您阅读我的帖子。

1 个答案:

答案 0 :(得分:1)

那应该是小写的:

 $data['results'] = $this->vgs_model->pcList();
相关问题