Kevin Brown
Kevin Brown

Reputation: 12650

Codeigniter select multiple rows?

How do I select multiple rows from SQL?

ie. $results->row(1,2,3,4,5,10)

Upvotes: 0

Views: 5463

Answers (1)

Marc W
Marc W

Reputation: 19241

Are you using ActiveRecord? If so, you can use the where_in() method when making your query. It's not something you do after the query is finished, as you seem to be doing in your example.

$this->db->where_in('id', array(1,2,3,4,5,10));
$query = $this->db->get('myTable');
// This produces the query SELECT * FROM `myTable` WHERE `id` IN (1,2,3,4,5,10)

See the this CodeIgniter docs section for more info on SELECT statement support.

Upvotes: 2

Related Questions