|
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Mtest:db
Filename: models/mtest.php
Line Number: 14
Fatal error: Call to a member function query() on a non-object in D:\xampp\htdocs\system\application\models\mtest.php on line 14
Controller代码
<?php
class Test extends Controller {
function Test(){
parent::Controller();
}
function index(){
$this->load->helper('form');
$data['title'] = "Users add.";
$data['headline'] = "Welcome! to User System.";
$this->load->vars($data);
$this->load->view('user');
}
function save(){
$this->load->helper('url');
$this->load->model('Mtest');
$this->Mtest->addUser();
redirect('test/thanks','refresh');
}
function thanks(){
echo "<h1>Thank you !</h1>";
}
}
?>
model代码
<?php
class Mtest extends Model{
function Mtest(){
parent::Model();
}
function adduser(){
$data=array(
'name'=> $this->input->post('name'),
'age'=> $this->input->post('age'),
'sex'=> $this->input->post('sex')
);
$this->db->query('SELECT * FROM users');
}
}
?> |
|