2017-03-29 50 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