In My PHP project I want to make prepare statement to insert point. I did it as fallows
$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);
but it shows following error message
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
What is the problem here? dl_location datatype is GEOMETRY
It work like this.
$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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.