2013-02-17 79 views
-1

找遍周圍的例子,但我得到一個奇怪的結果笨URI不工作 - 404錯誤

我想有以下發生/頁/ 1 URL從數據庫中返回第1行的標記列的頁表。

控制器

 

    public function index() 
     { 
      $id = $this->uri->segment(2); 
      $content = $this->page->specificMarkup($id); 
      $this->template->set('nav', 'support'); 
      $this->template->set('content', $content); 
      $this->template->load('master', 'contact'); 
     } 

模型

 

    public function specificMarkup($id) 

     { 
     $query = $this->db->get_where('pages', $id); 
     $row = $query->row(); 
     return $row->markup; 
     } 

當我專門設置的$ id,但現在當我嘗試使用部分返回404錯誤它的工作原理,用戶指南給我的感覺這應該工作。

回答

0

我會爲其他人遇到的問題回答我自己的問題。

1.

的模型需要

public function specificMarkup($id) 

    { 
    $query = $this->db->get_where('pages', array('id' => $id)); 
    $row = $query->row(); 
    return $row->markup; 
    } 

2. 他們確實需要在routes.php文件中的條目

$路線[「頁/(:NUM )'] ='網頁/索引/ $ 1'

這是如此codeigniter知道在哪裏指導交通