I need help regarding AJAX search function

I’ve created a search function using AJAX and whenever i add my third condition by using another comma ‘,’ the search wont work properly. this is the search() function.


What’s the third condition? If you used only the third condition and temporarily removed the other conditions, does it still work ?

This is the the code with the third condition, i added the ‘quantity’. if i add that, the search will not work properly anymore.


Normally the condirions are in an AND relation. Is this what you desire? Check the generated sql.

It looks like you’re using the LIKE operator to match integer fields?

what operator should i use to match integer fields?

For an equality test: simply ->where(['field_name' => $value]).

For less than, greater than or not equals: ->where(['field_name <' => $value]) or ->where(['field_name >' => $value]) or ->where(['field_name !=' => $value]). “Less than or equal to” and “greater than or equal to” should be fairly obvious at this point.

There are also query expressions, but IMO they’re overly complicated for most uses, and likely to just cause confusion right now.

If you want to look for an integer that contains the search value (like “1234” would match when the user searches for “23”), that’s going to get messy. Certainly do-able with casting, but I think probably not what you’re looking for.

1 Like