Skip to content
Advertisement

CodeIgniter : how to write where_in OR where_in query?

I’m using codeigniter to query a database, and I need to conditionally compare arrays in the where clause.

So basically I want to do: where_in OR where_in depending on what array has data in it. So I will have either an array of user_id OR an array of area_id’s.

I’m not sure how to combine the where_in comparison. This is the query i need to amends:

JavaScript

I don’t think there is a or_where_in function that I can find.

Can I do it like this or do I need a rethink?

Thanks

Advertisement

Answer

Yes, there is a or_where_in function in Codeigniter.

Example

JavaScript

Syntax:

JavaScript

Parameters:

JavaScript

Returns:

JavaScript

Return type:

JavaScript

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

If more help needed, I’m happy to help. Happy Coding.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement