Search code examples
phpmodelcodeigniter-4

How to have multiple Where but with OR operator in Codeigniter 4 model?


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


Solution

  • 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'