问题
I can't seem to find where documented to successfully prepare a statement that uses the POINT data type.
This previous question (How to use POINT mysql type with mysqli - php) shows something marked as correct, but it doesn't work. I even tried using their simple query in their example:
$stmt = $this->conn->prepare("INSERT INTO days(day,POINT(lat,lon)) VALUES(?,?,?)");
$stmt->bind_param("sdd", $day, $lat, $lon);
This just simply returns and error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(lat,lon)) VALUES(?,?,?)' at line 1
回答1:
Try like below;
$stmt = $this->conn->prepare("INSERT INTO days(day,column_name) VALUES(?,POINT(?,?))"); //column_name is name of of column that you want to insert POINT(lat,lon)
$stmt->bind_param("sdd", $day, $lat, $lon);
$stmt->execute();
来源:https://stackoverflow.com/questions/43093902/how-to-prepare-sql-statement-with-point-using-mysqli-when-using-insert