【发布时间】:2015-12-02 21:52:37
【问题描述】:
我使用 PDO 对数据库执行 postgresql 查询,然后以如下形式返回响应字符串:
POINT(23.7336253085595 38.0002872112492)
如何获取这些字符串的编号并将它们存储到不同的变量中?
这是我发送查询问题的代码:
include 'postgreConnect.php';
$maxGid = 1084;
for ($rowPostGis=1; $rowPostGis<=$maxGid;$rowPostGis++){
$stmt = $dbconn->prepare("SELECT ST_AsText(ST_Transform(geom, 4326)) AS geom FROM part_athens_centroids WHERE gid = :rowPostGis;");
$stmt->execute(array('rowPostGis' => $rowPostGis));
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$geom = $row['geom'];
echo($geom);
//echo($geom);
}
}
【问题讨论】:
-
您可以将您的SQL设置为返回json,然后将其转换为php数组。在这里查看:stackoverflow.com/questions/3068683/…
标签: json postgresql postgis