Php Sqlite acos function

Viewed 200

In Laravel I've got a query builder method for ordering items based on the users location with long and 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?

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

acos function in Sqlite

0 Answers
Related