12-10-2009, 09:30 AM

[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

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

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'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