我正在尝试使用一个简单的联接查询从2个表中选择数据,第一个是倡议,第二个是包含带有点的空间表的位置。但是我认为我用联接查询犯了一个新手错误。
<?php
$qx = "SELECT initiatives.location_id as init_location, locations.location as locations_coord, locations.name as locations_name FROM locations JOIN initiatives on initiatives.location_id = locations.id";
if ($query = $connect->query($qx)) {
echo "done";
}
else {
echo $connect->error;
}
// $count = $query->num_rows;
$row = 1;
while ($fetch = $query->fetch_array(MYSQLI_ASSOC)) {
echo "test A";
$point = $fetch['ST_AsText(locations_coord)'];
$point = str_replace(array(
"POINT(",
")"
) , array(
"",
""
) , $point);
$point = str_replace(" ", ",", $point);
}
这不允许我将St用作文本,不确定为什么,如果我对它可以工作的位置进行查询
我如何解决:
$qx = "SELECT initiatives.location_id as init_location, ST_AsText(locations.location) as locations_coord, locations.name as locations_name FROM locations JOIN initiatives on initiatives.location_id = locations.id";