Pass array to where in Codeigniter Active Record

前端 未结 4 1865
傲寒
傲寒 2020-12-05 22:50

I have a table in my database with adminId and clientId

There might be 20 records with the adminId of the logged in user and I\'m trying to pull a list of clients.

4条回答
  •  悲&欢浪女
    2020-12-05 23:47

    From the Active Record docs:

    $this->db->where_in();
    

    Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate

    $names = array('Frank', 'Todd', 'James');
    $this->db->where_in('username', $names);
    // Produces: WHERE username IN ('Frank', 'Todd', 'James')
    

提交回复
热议问题