【问题标题】:How to use WHERE CLAUSE in Codeigniter 4如何在 Codeigniter 4 中使用 WHERE CLAUSE
【发布时间】:2021-07-15 11:32:29
【问题描述】:

您好,我有 2 张桌子学生和教师 我想将它们称为我的索引(视图),所以我想出了如何加入它们。但我有一个问题,我需要将这两个表分成一个类别,但我不知道代码。有人可以帮帮我吗?

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

谢谢

【问题讨论】:

    标签: php sql codeigniter-4


    【解决方案1】:
    public function getStudentReguler()
    {
        return $this->db->table('student')
            ->join('faculty', 'faculty.id_faculty = student.id_student')
            ->where('category', 'A')
            ->get()->getResultArray();
    }
    

    请试试这个:

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

    【讨论】:

    • 我不是 php 开发人员。但试图提供帮助。这段代码遇到了什么问题?
    • opps 我的问题,有一个错字。但它有很大帮助,谢谢!
    • 不客气。很高兴知道问题已解决。最好的方法。
    猜你喜欢
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    • 2020-09-13
    • 2022-12-27
    • 2020-05-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多