title: Laravel 5.1 Eloquent escape string parameter (havingraw)
body: <p>i am receiving a string parameter that i would like to use havingRaw with:</p>
  
  <p>string i am receiving:</p>
  
  <pre><code>$searchString = Input::get('q');//example:party beach
  </code></pre>
  
  <p>i have found in different question that i should use this to prevent sql injection:</p>
  
  <pre><code>$searchStringEsc = DB::connection()-&gt;getPdo()-&gt;quote($searchString);
  </code></pre>
  
  <p>the problem i am having is, when i insert into my query with havingRaw, since my string is now escaped `party beach` it return null, but when i insert the un-escaped string, it works fine.</p>
  
  <pre><code>-&gt;havingRaw('search rlike replace("'.$searchStringEsc.'", " ", "|")')
  </code></pre>
  
  <p>is there another way to escape raw parameters? thank you</p>
  
  <p>EDIT--
  Full Query (i am doing a search query where the user can put in city name, establishment name, any tags tagged to the establishment etc...)</p>
  
  <pre><code>            $results = DB::table('events')
              -&gt;leftJoin('event_tag', 'events.id', '=', 'event_tag.event_id')
              -&gt;join('tags', 'tags.id', '=', 'event_tag.tag_id')
              -&gt;join('establishments', 'establishments.id', '=', 'events.establishment_id')
              -&gt;join('cities', 'establishments.city_id', '=', 'cities.id')
              -&gt;leftJoin('artist_event', 'events.id', '=', 'artist_event.event_id')
              -&gt;join('artists', 'artist_event.artist_id', '=', 'artists.id')
              -&gt;leftJoin('event_music', 'events.id', '=', 'event_music.event_id')
              -&gt;join('musics', 'musics.id', '=', 'event_music.music_id')
              -&gt;select('events.id as evId', 'events.slug as evSlug', 'events.name as evName',
                  'events.cover_path as estPath','establishments.establishment_type_id as estType',
                  'establishments.name as estName', 'events.start_date as evStart', 'events.end_date as evEnd',
                  'cities.name as ciName',
                  DB::raw('CONCAT_WS(",",
                          GROUP_CONCAT(distinct tags.name),
                          GROUP_CONCAT(distinct artists.name),
                          GROUP_CONCAT(distinct cities.name),
                          GROUP_CONCAT(distinct events.name),
                          GROUP_CONCAT(distinct musics.name)
                          ) as search'))
              -&gt;where('events.end_date','&gt;=', DB::raw('NOW()'))
              -&gt;where('establishments.is_active','=',1)
              -&gt;groupBy('events.id')
              -&gt;havingRaw('search rlike replace("'.$searchString.'", " ", "|")')
              -&gt;orderBy('events.total_visited', 'desc')
              -&gt;take(5)-&gt;get();
  </code></pre>
  
  <p>if i leave it as $searchString (unscaped string), it works fine.
  if i change it to $searchStringEsc (escaped string) it return null</p>