Reputation: 3
i would like to have this query
select ID, Username from tblUsers where ID = %1 OR Username = %1
in Codeigniter 4 model.
i found that Codeigniter model support multiple where, but it using "AND" operator.
and i would like to avoid using Query builder.
is this can be done? thanks
Upvotes: 0
Views: 4919
Reputation: 54
You can pass the string into the where
$yourmidel->where("ID = %1 OR Username = %1");
And if something which your are passing into query string must be in double ""
or single ''
quoted.
Like username = '%1'
Upvotes: 0
Reputation: 5507
This answer is just pointing you to the correct locations in the userguide
OrWhere There is an Or Where - $builder->orWhere() in the users guide
Search for $builder->orWhere() on that page
Write your own queries To write your own queries you can use something like $db->query
Binding of query parameters Binding of query parameters
Upvotes: 3