Laravel select like %value% wildcard query
laravel, laravel-4
Solution
you are misplacing the % % operators, notice the difference below - they should not be put aside the `?` placeholder, rather inside:
$query = "select *, day(WN_DATE) WN_DAYOFMONTH, month(WN_DATE) WN_MONTH, year(WN_DATE) WN_YEAR from mytable where year(WN_DATE) like ? order by WN_DATE DESC";
$param = '%'.$_SESSION['filterOn'].'%';
$result = DB::select($query , array($param));
Problem
Does anybody know why the LIKE part is not working in Laravel 4? ``` $a = DB::select('select *, day(WN_DATE) WN_DAYOFMONTH, month(WN_DATE) WN_MONTH, year(WN_DATE) WN_YEAR from mytable where year(WN_DATE) like %?% order by WN_DATE DESC', array($_SESSION['filterOn'])); ``` When using `like ?` , the this is working but when I add the `%`, as in `like %?%` then it does not work anymore.