Php Sqlite acos function

Php Sqlite acos function



In Laravel I've got a query builder method for ordering items based on
the users location with long and latitude.


Laravel


long


latitude



It looks like this:


public function location($location)

$location = explode(',', $location);

$lat = $location[0];
$long = $location[1];

return $this->builder->select(DB::raw(sprintf('(
6371 * acos (
cos ( radians(%s) )
* cos( radians( lat ) )
* cos( radians( lng ) - radians(%s) )
+ sin ( radians(%s) )
* sin( radians( lat ) )
)
) AS distance', $lat, $long, $lat)))
->orderBy('distance');



The problem is that I use a sqlite database. And acos is not supported. How could I get this to work with sqlite?


acos



Already saw this but this is not for php I guess?



acos function in Sqlite




0



Thanks for contributing an answer to Stack Overflow!



But avoid …



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Popular posts from this blog

Malaysia to Papua New Guinea by motorcycle?

List of Bhojpuri films

PHP code is not being executed, instead code shows on the page