CodeIgniter where_in condition

36 Views

CodeIgniter where_in condition

Codeigniter | where_in 

The where_in() allows you to pass an array in 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')

?>

 

Tags:-
Codeigniter