2014-09-03 65 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