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

[eluser]JamesTaylor[/eluser]
I have the following sql function in my model which works as expected in its current state, but i would like convert it to a CI active records statement

Code:
$sql = "SELECT ClubID, Name, Lat, Lng, Address1, Address2, Address3, County, PostCode, TelArea, TelNo, Web, Email, Review, ( 3959 * acos( cos( radians($Lat) ) * cos( radians( Lat ) ) * cos( radians( Lng ) - radians($Lng) ) + sin( radians($Lat) ) * sin( radians( Lat ) ) ) ) AS distance FROM golfcourses HAVING distance < $Dist ORDER BY distance LIMIT 0 , 20";
        
$query = $this->db->query($sql);
I would like to add some pagination to the results so am wanting to convert the above sql into a CI active records statement.

I'm not sure but does the CI pagination only work with active records? I've had it work on other elements using active record without any problems but i can't get it to work on the above traditional sql statement?

help converting the sql would be much appreciated anyway, i'll keeep trying in the mean time!

Thanks

James


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