2017-03-29 26 views
0

我似乎无法找到记录的位置,以便成功准备使用POINT数据类型的语句。如何在使用INSERT时使用mysqli编写带有POINT的SQL语句

上一个问题(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 
+2

'INSERT INTO days(day,point)VALUES(?,POINT(?,?))'!? – JustOnUnderMillions

回答

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(); 
+0

太棒了!非常感谢:-)我不敢相信我无法在任何地方找到记录 – KingRidgehead