Level 4
My XAMPP control panel says I'm using MySQL (which supports this function), but info files about my XAMPP mentions I'm using MariaDB, which doesn't support this.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to display results that are within $distance (GPS coordinates).
<?php
namespace App\Http\Controllers;
use App\Record;
class SearchResultsController extends Controller
{
public function search()
{
$lon = 0;
$lat = 0;
$distance=1000000;
return Record::whereRaw('ST_Distance_Sphere(point(latitude, longitude),POINT('.$lat.','.$lon.')) < '.$distance)->get();
}
}
But I'm getting ERROR:
SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION database.ST_Distance_Sphere does not exist (SQL: select * from `records` where ST_Distance_Sphere(point(latitude, longitude),POINT(0,0)) < 1000000)
I don't know what to try anymore.
Please or to participate in this conversation.