使用INSERT时如何使用mysqli使用POINT准备SQL语句 [英] How to prepare SQL statement with POINT using mysqli when using INSERT

查看:89
本文介绍了使用INSERT时如何使用mysqli使用POINT准备SQL语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到要成功准备使用POINT数据类型的语句的文档记录.

I can't seem to find where documented to successfully prepare a statement that uses the POINT data type.

上一个问题(如何与POINT mysql类型一起使用mysqli-php )显示标记为正确的内容,但不起作用.我什至尝试在示例中使用他们的简单查询:

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);

这只是返回并出错:

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

这篇关于使用INSERT时如何使用mysqli使用POINT准备SQL语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆