我似乎找不到要成功准备使用POINT数据类型的语句的文档记录在哪里.
前面的问题(How to use POINT mysql type with mysqli – php)显示了标记为正确的内容,但是它不起作用.我什至尝试在示例中使用他们的简单查询:
$stmt = $this->conn->prepare("INSERT INTO days(day,POINT(lat,lon)) VALUES(?,?,?)");
$stmt->bind_param("sdd", $day, $lat, $lon);
这只是返回并出错:
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
解决方法:
尝试如下
$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();