CodeIgniter where_in condition

Last updated 4 years, 6 months ago | 7196 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')

?>