在我的PHP项目中,我想制作插入点的准备语句。 我做了它作为休耕
$query = "update d_location set dl_location = GeomFromText('POINT(:lat :lon)') where dl_id = :id";
echo $query;
$stmt = $conn->prepare($query);
$params = array(
'lat'=>$lat,
'lon'=>$lon,
'id'=>$d_id
);
$stmt->execute($params);
但它显示以下错误消息
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
这是什么问题? dl_location数据类型是GEOMETRY
答案 0 :(得分:1)
它的工作原理如下。
$location = 'POINT(' . $lat . " " . $lon . ')';
$query = "update d_location set dl_location = GeomFromText(:location) where dl_id = :id";
$stmt = $conn->prepare($query);
$params = array(
'location'=>$location,
'id'=>$d_id
);
$stmt->execute($params);