Abhishek Joshi Abhishek Joshi - 4 months ago 62
PHP Question

Call to undefined method CI_DB_mysql_driver::row_array()

Hey i am novice in CI so please forgive! I am trying to join 2 tables in codeigniter and i am getting here these error in my code


Call to undefined method CI_DB_mysql_driver::row_array() in
C:\xampp\htdocs\Hostel\application\models\payfees.php on line 16.


My Code for the method is here like these

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();
}

Answer

Don't forget the missing ->get() method. Plus, remove the WHERE in the string:

$where = "name='Joe' AND status='boss' OR status='active'";

http://www.codeigniter.com/userguide2/database/active_record.html

I'd suggest use an array instead:

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();
               //  ^
}