嘿,我是CI的新手所以请原谅!我正在尝试在codeigniter中加入2个表,我在我的代码中遇到这些错误
调用未定义的方法CI_DB_mysql_driver :: row_array() 第16行的C:\ xampp \ htdocs \ Hostel \ application \ models \ payfees.php。
我的方法代码就像这些
public function payu($id,$month){
$where = "where generatebills.student_id='".$id."' and generatebills.month='".$month."'";
$query = $this->db->select('*')
->from('generatebills')
->join('student','student.student_id=generatebills.student_id')
->where($where);
return $query->row_array();
}
答案 0 :(得分:0)
不要忘记丢失的->get()
方法。另外,删除字符串中的WHERE
:
$where = "name='Joe' AND status='boss' OR status='active'";
http://www.codeigniter.com/userguide2/database/active_record.html
我建议改用数组:
public function payu($id,$month)
{
// $where = "generatebills.student_id='".$id."' and generatebills.month='".$month."'";
$where = array(
'generatebills.student_id' => $id,
'generatebills.month' => $month,
);
$query = $this->db->select('generatebills.*')
->from('generatebills')
->join('student','student.student_id = generatebills.student_id')
->where($where);
return $query->get()->row_array();
// ^
}