Skip to content Skip to sidebar Skip to footer

Codeigniter Or_where_in

I am trying to combine these two queries in Codeigniter. So the row either has to have the user_id of $user eg 3 OR have an id matching the array $repost. I know how to do or_where

Solution 1:

$this->db->or_where_in();

Syntax:

or_where_in([$key = NULL[, $values = NULL[, $escape = NULL]]])

Parameters:

$key (string) – The field tosearch
$values (array) – The values searched on
$escape (bool) – Whether toescapevaluesand identifiers

Returns:

DB_query_builder instance

Return type:

object

Generates a WHERE field IN(‘item’, ‘item’) SQL query, joined with ‘OR’ if appropriate.

More information here: https://codeigniter.com/userguide3/database/query_builder.html?highlight=or_where_in#CI_DB_query_builder::or_where_in

Post a Comment for "Codeigniter Or_where_in"