2014-09-03 35 views
0

喜IM使得在laravel的应用程序,我有一个搜索栏,我需要找到一个词IA句子为例laravel雄辩的数据库行搜索词

在表中我有场问题

so when i enter "Lequel" it give me "Lequel de ces animaux n'est pas un singe?" 

但变薄的是,在雄辩有像,但它不给我结果,我必须进入全句找到它

$questions = DB::table('geolocalizedQuestion') 
            ->where('theme','LIKE',$the) 
            ->orWhere('question','LIKE',$quest) 
            ->paginate(10); 

          return View::make('home.home') 
          ->with('user', Auth::user()) 
          ->with('theme', $theme) 
          ->with('the' , $the) 
          ->with('questions',$questions); 

是有帮助的任何建议:) thx

回答

1

你错过了%

$questions = DB::table('geolocalizedQuestion') 
           ->where('theme', 'LIKE', '%'.$the.'%') 
           ->orWhere('question', 'LIKE', '%'.$quest.'%') 
           ->paginate(10); 
1

$的,$任务就是寻找字符串,那么你需要添加到您查询 '%值%' 包含行

$the = "%$the%"; 
$quest = "%$quest%"; 

more info here

+0

THX家伙它工作:) – 2014-09-03 08:38:36