CodeIgniter where_in condition

Last updated 1 year, 3 months ago | 532 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')

?>