0

I am using postegresql with php (specifically the postgis extension and the ST_Contains function) for a spatial related query.

The query is the following:

$within = pg_exec($db, 
"select st_contains(st_geomfromtext('POLYGON((
                                             41.7750000000 19.3666666667,
                                             34.4750000000 19.3666666667,
                                             34.4750000000 29.6500000000,
                                             41.7750000000 29.6500000000, 
                                             41.7750000000 19.3666666667))'), 
                                             ST_MakePoint('$lat', '$lng'))" );



$rows = pg_fetch_all ($within);
echo json_encode($rows);

The result of this is [{"st_contains":"t"}] or [{"st_contains":"f"}], however i want it to be just true or false/ 0 or 1 so i can be able to use it on an if condition. I tried using the EXISTS on the postgresql query but it messes up the query and gives wrong results. Is there any way to get a normal true/fase/0/1 out of this query so i can use it latter on? Thanks.

G90DD
  • 29
  • 1
  • 1
  • 5

0 Answers0