In my web service I have a problem with bindParams
. Here is my code:
$stmt = $this->db->prepare("SELECT data FROM sless WHERE ST_CONTAINS(data.area, Point(:query))");
$stmt->bindParam(':query', $queryText, PDO::PARAM_STR);
but :query
variable isnt correctly adapted this code.
When I echo $queryText
it gives 29.029087,40.990361
perfectly. But in the code it's not working. By the way when I write 29.029087,40.990361
latitude and longitude instead of the variable :query
my code working perfectly. Here is the code:
$stmt = $this->db->prepare("SELECT data FROM sless WHERE ST_CONTAINS(data.area, Point(29.029087,40.990361))");
How can I solve the problem?
Try both coordinate separately
list($lat, $lng) = split(',', $queryText);
$stmt = $this->db->prepare("SELECT data FROM sless WHERE ST_CONTAINS(data.area, Point(:lat,:lng))");
$stmt->bindParam(':lat', $lat, PDO::PARAM_STR);
$stmt->bindParam(':lng', $lng, PDO::PARAM_STR);