我在Mac上使用MAMP在本地托管CodeIgniter网站。
每当我尝试加载模型时,网站都会运行HTTP 500错误,我不确定会发生什么。我怀疑我忽略了一些非常小的东西,但我只是没有看到它。
控制器:main.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Main extends CI_Controller {
public function index()
{
//load content model
$this->load->model('content_model');
//grab content from the database
//$data['content'] = $this->content_model->get_content(0);
//display content
$this->load->view('main_view');
}
}
?>
型号:content_model.php
<?php
class Content_model extends CI_Model {
function __construct()
{
//Call the Model constructor
parent::__construct();
}
public function get_content($navID)
{
$this->db->limit(1);
$this->db->where('navID', $navID);
$query = $this->db->get('pmlSiteContent');
return $query->result();
}
?>
autoload.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$autoload['packages'] = array();
$autoload['libraries'] = array('database', 'session');
$autoload['helper'] = array('url', 'form', 'file');
$autoload['config'] = array();
$autoload['language'] = array();
$autoload['model'] = array();
?>
database.php中
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost:8889';
$db['default']['username'] = 'root';
$db['default']['password'] = 'root';
$db['default']['database'] = 'pmlcms';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
?>
我错过了什么?非常感谢帮助,谢谢!
答案 0 :(得分:1)
错误发生在content_model.php
你错过了班级的最后阶段。使用结束php
标记