我正在按照教程,並得到了500問題。我不確定問題是否由模型引起。 我的模型:500內部服務器錯誤CodeIgniter
<?php
class Cat_model extends CI_Model{
public function __construct()
{
$this->load->database();
}
function getCategory($id){
$data = array();
//select one row matching that ID from the categories table
$options = array('id'=>$id);
$q = $this->db->get_where('categories',$options,1);
if($q->num_rows()>0){
$data = $q->row_array();
}
$q->free_result();
return $data;
}
function getAllCategories(){
$data = array();
$q = $this->db->get('categories');
if($q->num_rows()>0){
foreach ($q->result_array() as $row){
$data[] = $row;
}
}
$q->free_result();
return $data;
}
}
我的控制器:
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{//homepage
$data['title'] = "Welcome to TM testDIY";
$data['navlist'] = $this->cat_model->getAllCategories();
$this->load->var($data);
$this->load->view('template');
}
}
數據庫
$db['default']['database'] = 'testDIY';
,我已經在自動加載自動加載文件中的模型。
如果我清空數據庫或將一些隨機名稱放在那裏,它不會顯示500內部服務器錯誤,而是顯示一些有意義的錯誤消息。 現在我無法弄清楚這個問題,誰都可以幫忙?
這意味着一般的服務器錯誤。也許這是一個不好的要求。 – gooddadmike 2012-03-08 19:44:54