I have a query:
DB::select('select * from student where name like "%?%" or description like "%?%"',[$keyword,$keyword])
but I got empty result, which shouldn't be. I think it might take "?" instead of my keyword, how should I modify it?
I have a query:
DB::select('select * from student where name like "%?%" or description like "%?%"',[$keyword,$keyword])
but I got empty result, which shouldn't be. I think it might take "?" instead of my keyword, how should I modify it?
You might wanna use that statement like this.
DB::table('students')->where('name','LIKE',"%$keyword%")->orWhere('description','LIKE',"%$keyword%")->get();
You can do it in this way as well:
$result = DB::table('students')->where(function ($query) use ($keyword) {
$query->orWhere('name', 'like', "%".$keyword."%");
$query->orWhere('description', 'like', "%".$keyword."%");
})->get();