这是我的控制器:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Order extends CI_Controller {
public function index($id=-1) {
$this->load->model('order');
}
}
当我尝试打开相应的 url 时,我得到错误 500。奇怪的是,我在另一个控制器上以相同的方式加载模型而没有问题。
这里是路线和模型以防万一:
路线:
$route['order/(:num)'] = "order/index/$1";
模型:
<?php
class Order extends CI_Model {
var $fullname = '';
var $email = '';
var $address = '';
var $phone = '';
var $notes = '';
var $facebook = '';
//var $canvases = '';
var $admin_notes = '';
var $status = '';
var $id = '';
var $date = '';
var $price = '';
//var $emailStatus_recivedOrder = '';
//var $emailStatus_sendedOrder = '';
//var $emailStatus_askFeedback = '';
function __construct() {
// Call the Model constructor
parent::__construct();
}
function get($search_query='', $per_page=5, $skip=0) {
if($search_query != '') {
$this->db->or_where('id', $search_query);
$this->db->or_where('email', $search_query);
$this->db->or_where('fullname', $search_query);
$this->db->or_where('phone', $search_query);
}
$query = $this->db->get('entries', $per_page, $skip);
return $query->result();
}
function count_all($search_query='') {
if($search_query != '') {
$this->db->or_where('id', $search_query);
$this->db->or_where('email', $search_query);
$this->db->or_where('fullname', $search_query);
$this->db->or_where('phone', $search_query);
}
$this->db->from('entries');
return $this->db->count_all_results();
}
function get_by_id($id) {
return $this->db->get_where('entries', array('id' => $id), 1);
}
function get_active_orders_count() {
$this->db->where('status', '1');
$this->db->from('entries');
return $this->db->count_all_results();
}
function insert_entry() {
$this->fullname = $this->input->post('fullname');
$this->email = $this->input->post('email');
$this->address = $this->input->post('address');
$this->phone = $this->input->post('phone');
$this->facebook = $this->input->post('facebook');
$this->notes = $this->input->post('notes');
$this->admin_notes = $this->input->post('admin_notes');
$this->status = $this->input->post('status');
$this->date = date('Y-m-d H:i:s');
$this->db->insert('entries', $this);
}
function update_entry() {
$this->admin_notes = $this->input->post('admin_notes');
$this->db->update('entries', $this, array('id' => $this->input->post('admin_notes')));
}
}
错误是:发生数据库错误
无法使用提供的设置连接到您的数据库服务器。
文件名:core/Loader.php
行号:346