Welcome Guest, Not a member yet? Register   Sign In
Complex SQL -> converting to active records
#4

[eluser]Phil Sturgeon[/eluser]
Code:
$this->db->select('ClubID, Name, Lat, Lng, Address1, Address2, Address3, County, PostCode, TelArea, TelNo, Web, Email, Review')
    ->select('( 3959 * acos( cos( radians($Lat) ) * cos( radians( Lat ) ) * cos( radians( Lng ) - radians($Lng) ) + sin( radians($Lat) ) * sin( radians( Lat ) ) ) ) AS distance', FALSE)
    ->having('distance <', $Dist)
    ->order_by('distance')
    ->limit(20);

$query = $this->db->get('golfcourses');

Or something along those lines.


Messages In This Thread
Complex SQL -> converting to active records - by El Forum - 12-10-2009, 09:30 AM
Complex SQL -> converting to active records - by El Forum - 12-10-2009, 10:05 AM
Complex SQL -> converting to active records - by El Forum - 12-10-2009, 10:46 AM
Complex SQL -> converting to active records - by El Forum - 12-10-2009, 10:47 AM
Complex SQL -> converting to active records - by El Forum - 12-10-2009, 11:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB