我正在尝试将 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();
}
}
看法
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);
}
}