i need to do a DB query based on a distance from a point
for that I use geo-coordinates as such
$query->where ('SQRT(POWER(((latitude - (".$latitude."))*69.1),2) + POWER(((longitude - (".$longitude."))*69.1),2))"','<',100)
I get a Fuel\Core\Database_Exception [ 1064 ] error with the value of $latitude , $longitude being escaped ( they r not integers ) as well as the "69.1" number I am using.
any suggestions as to how to work around this?
thank you
Phil : this is what the error message looks like :
: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '37`.`48`))*`69`.`1`),2) + POWER(((longitude - (-122`.`33))*69`.`1),2)) * 1` <= '' at line 1
the complete line is here :
SQRT(POWER(((latitude - (`37`.`48`))*`69`.`1`),2) + POWER(((longitude - (-122`.`33))*69`.`1),2)) * 1` <= '10' ;
Jelmer, thank you for pointing me in the right direction.
update : It worked like a charm Jelmer.
for those who need more details :
this is what it would look like at
$distance = "SQRT(POWER(((latitude - (".$latitude."))*69.1),2) + POWER(((longitude - (".$longitude."))*69.1),2));
$query->where(DB::expr($distance),'<', 10);