人.php
<?php
class Person extends CI_Controller {
public function index()
{
echo 'Hello World! person';
$this->load->model('PersonModel');
$this->PersonModel->get_last_ten_entries();
}
}
?>
人模型.php
<?php
class PersonModel extends CI_Model {
var $title = '';
var $content = '';
var $date = '';
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function get_last_ten_entries()
{
$query = $this->db->get('entries', 10);
return $query->result();
}
function insert_entry()
{
$this->title = $_POST['title']; // please read the below note
$this->content = $_POST['content'];
$this->date = time();
$this->db->insert('entries', $this);
}
function update_entry()
{
$this->title = $_POST['title'];
$this->content = $_POST['content'];
$this->date = time();
$this->db->update('entries', $this, array('id' => $_POST['id']));
}
}
?>
收到此错误:
Fatal error: Call to a member function get() on a non-object in C:\wamp1\www\ci\CodeIgniter_2.1.3\application\models\personModel.php on line 18
我该如何解决这个错误?