我想MySQL的使用CodeIgniter連接。我得到這個錯誤:笨模型未找到
load->database();
$query = $this->db->get('student'); return $query->result(); } } ?>
Fatal error: Class 'Student_model' not found in
C:\wamp\www\CodeIgniter\system\core\Loader.php on line 303
這裏是我的代碼:
模型
class Student_model extends CI_Model
{
function __Construct()
{
parent::__Construct();
}
public function student_getall()
{
$this->load->database();
$query = $this->db->get('student');
return $query->result();
}
}
VIEW
foreach($query as $row)
{
print $row->fname;
print $row->lname;
print $row->roll;
print $row->address;
print "<br>";
}
控制器
class Student extends CI_Controller
{
function __Construct()
{
parent::__Construct();
}
public function getall()
{
$this->load->model('student_model');
$data['query'] = $this->student_model->student_getall();
$this->load->view('student_view',$data);
}
}
確保您的型號文件名是小寫 – Ula