0
我是codeIgnitor的新手,不斷收到錯誤404,請告訴我哪裏錯了,下面是我的結構和頁面。 數據庫名稱:stoma_store_suppliers, 數據庫字段:供應商ID,supplier_name,supplier_phoneCodeIgniter 404
模型Page:_____________ suppliers.php
<?php
Class Suppliers extends CI_Model
{
public function get_suppliers($supplierid) {
if($supplierid != FALSE) {
$query = $this->db->get_where('store_suppliers', array('supplierid' =>$supplierid));
return $query->row_array();
}
else {
return FALSE;
}
}
}
?>
控制器Page__________ suppliers.php
<?php if (!defined('BASEPATH'))exit('No direct script access allowed');
class Suppliers extends CI_Controller {
public function show($supplierid) {
$this->load->model('suppliers');
$store_suppliers = $this->suppliers->get_suppliers($supplierid);
$data['supplier_name'] = $suppliers['supplier_name'];
$data['supplier_phone'] = $suppliers['supplier_phone'];
$this->load->view('index', $data);
}
}
?>
查看頁面: 指數.php
<?php print $supplier_name; ?>
<?php print $supplier_phone; ?>
放置在視圖上的'index.php'的路徑和控制器文件名應該是'Suppliers.php' –
沒有與控制器相同的型號名稱。 Suppliers_model會更好名稱你應該看看codeigniter phpstyle指南 – user4419336
沃爾夫岡,我不知道你的意思是沒有模型名稱相同的控制器,你能解釋一下,thx? – DEDE