Search code examples
phpsqlcodeigniter-4

How to use WHERE CLAUSE in Codeigniter 4


Hello i have 2 tables Student & Faculty i want to call them to my index(view), So I figured how to join them. but I have a problem, I need to divide these 2 tables into a category but I don't know the code. Can someone please help me?

 public function getStudentReguler()
{
    return $this->db->table('student')
        ->join('faculty', 'faculty.id_faculty = student.id_student')
        ->where('category', *i want to be like, where categor = A*)
        ->get()->getResultArray();
}

thank you


Solution

  • public function getStudentReguler()
    {
        return $this->db->table('student')
            ->join('faculty', 'faculty.id_faculty = student.id_student')
            ->where('category', 'A')
            ->get()->getResultArray();
    }
    

    Please try this:

    $this->db->select('*')
    ->from('student')
    ->join('faculty', 'faculty.id_faculty = student.id_student')
    ->where('category', 'A')
    ->get()->getResultArray();