Saturday, March 11, 2017

Laravel binding replace question mark from variable

I have area table like :

-----------------------------
id | name        | level
-----------------------------
1  | India       | country
2  | Some?thing  | country

in this table i have added a row with question mark and i want to select that row as follow Query in eloquent :

Area::select(*)->where("name","LIKE", "%Some?thing%")
               ->where("level","=","country")->get();

but this not give the result because question mark in string in where condition replaced with bindings

the raw sql generated is :

select * from area where name like %Somecountrything% AND level = ?

but i want it like

select * from area where name like %Some?thing% AND level = country



via Arjun

Advertisement