title: Laravel - SQLSTATE[HY000]: General error: 2031
body: <pre><code>$pois = Home::select(\DB::raw('*, st_distance_sphere(homes.geopoint, point(?, ?)) as dist'))
      -&gt;whereRaw('st_within(homes.geopoint, ST_Buffer(point(?, ?), 1))')
      -&gt;orderBy('dist')
      -&gt;get();
  </code></pre>
  
  <p>returns <code>Laravel - SQLSTATE[HY000]: General error: 2031</code> However this query below works</p>
  
  <pre><code>$pois = Home::selectRaw('*, st_distance_sphere(homes.geopoint, point('.$data["lng"].', '.$data["lat"].')) as dist')
      -&gt;whereRaw('st_within(homes.geopoint, ST_Buffer(point('.$data['lng'].', '.$data['lat'].'), 1))')
      -&gt;orderBy('dist')
      -&gt;get();
  </code></pre>
  
  <p>but it is vulnerable to SQLInjection. I've done the suggestions mentioned in stackoverflow. <a href="https://stackoverflow.com/questions/27337984/pdo-error-general-error-2031">PDO error: General error: 2031 [duplicate]</a></p>