CodeIgniter where_in condition

Last updated 5 years, 2 months ago | 8030 views 75     5

Tags:- CodeIgniter

Codeigniter | where_in 

The where_in() allows you to pass an array in the where clause. It generates a WHERE field IN ('item', 'item') SQL query.

Syntax:

$this->db->where('condition');
<?php

$ids = array('1', '2', '3');

$this->db->from('users');
$this->db->where_in('id', $ids);
$this->db->get();

// Produces: SELECT * FROM users WHERE id IN ('1', '2', '3')

?>