我有:
<?php
.........
$query="select osm_id, name, official_name, official_status, phone,'healthcare:speciality', way, ST_AsGeoJSON(ST_Transform(way,4326)) as way2 from opengeo.test_point";
$result = pg_query($query);
if (!$result) {
echo "Проблема с запросом " . $query . "<br/>";
echo pg_last_error();
exit();
}
$geojson = array(
'type' => 'FeatureCollection',
'features' => array(),
'crs' => array(
'type' => 'EPSG',
'properties' => array('code' => '4326')
)
);
while($myrow = pg_fetch_assoc($result)) {
$feature = array(
'type' => 'Feature',
'id' => $myrow["osm_id"],
'geometry' => json_decode($myrow["way2"], true),
'geometry_name' => 'way',
'properties' => array(
'name' => $myrow["name"],
'official_name' => $myrow["official_name"],
'addr:housenumber' => $myrow["addr:housenumber"],
'phone' => $myrow["phone"],
'healthcare:speciality' => $myrow["healthcare:speciality"],
'addr:street' => $myrow["addr:street"],
'opening_hours' => $myrow["opening_hours"]
)
);
// Add feature array to feature collection array
array_push($geojson['features'], $feature);
}
// Close database connection
pg_close($db);
header('Content-type: application/json',true);
echo json_encode($geojson);
?>
和$myrow["healthcare: specialty "]总是返回null,我尝试了其他列和所有列的":"返回null?
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
正在运行:
$query="select osm_id, name, official_name, official_status, phone,"healthcare:speciality", way, ST_AsGeoJSON(ST_Transform(way,4326)) as way2 from opengeo.test_point";