在PHP

时间:2015-12-02 13:48:35

标签: json postgresql postgis

我使用PDO对数据库执行postgresql查询,然后以以下形式返回作为repsonse字符串:

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);
}   
}

1 个答案:

答案 0 :(得分:1)

我会调查http://php.net/manual/en/function.explode.php这会将您的字符串转换为字符串数组,您可以使用http://php.net/manual/en/function.intval.php将每个字符串转换为int。您可能需要将查询结果裁剪为仅使用该http://php.net/manual/en/function.substr.php的数字。

相关问题