使用INSERT时如何使用mysqli使用POINT准备SQL语句

时间:2017-03-29 12:45:03

标签: php mysqli prepared-statement

我似乎无法找到成功准备使用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

1 个答案:

答案 0 :(得分: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();