title: Codeigniter and SQL/Haversine Formula
body: <p>I am using Codeigniter for a project and have some locations with latitude and longitude inputs on the database. I'm trying to get points within a certain distance (50km), and attempting it with the Haversine Formula. However, on my controller and view it doesn't print out the results. What I need to know is if there's any adjustments I need to make to get the model function working. </p>
  
  <p>Note: The DB table has the column names location_latitude and location_longitude. </p>
  
  <pre><code>//base function to compare distance with
  $setlat = 13.5234412; 
  $setlong = 144.8320897; 
  //query with Haversin formula 
  $awaka = "SELECT 'location_id',
      ( 3959 * acos( cos( radians(?) ) * cos( radians('location_latitude') ) * cos( radians('location_longitude') - radians(?) )
      + sin( radians(?) ) * sin( radians('location_latitude') ) ) ) AS 'distance'
      FROM 'locations' HAVING 'distance &lt; 5'";
   $result = $this-&gt;db-&gt;query($awaka, array($setlat, $setlong, $setlat));  
   echo $result; 
  </code></pre>