php - 如何在 mysqli - php 中使用 POINT mysql 类型

标签 php mysql mysqli

<分区>

基于 this table来自 PHP.net:

Type specification chars
Character   Description
i   corresponding variable has type integer
d   corresponding variable has type double
s   corresponding variable has type string
b   corresponding variable is a blob and will be sent in packets

I write code:

$stmt = $this->conn->prepare("INSERT INTO days(day,startLocation) VALUES(?,?)");
        $stmt->bind_param("ss", $day, $startLocation);

但问题是因为我在数据库中的 startLocation 字段使用类型 POINT,所以

如何在 mysql 中使用 POINT 数据类型创建 bind_param?

最佳答案

您应该使用 MYSQL 函数 POINT 以从纬度/经度转换

$stmt = $this->conn->prepare("INSERT INTO days(day,POINT(lat,lon)) VALUES(?,?,?)");
        $stmt->bind_param("sdd", $day, $lat, $lon);

关于php - 如何在 mysqli - php 中使用 POINT mysql 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27323915/

相关文章:

php - 如何正确使用mysqli进行查询和防止注入(inject)

php - 如何在 zend 文字中转义?

php - 为什么PHP+MySQL默认不使用文件缓存?

php - 未找到类 'SourceServer',使用 Steam 冷凝器库

mysql - Visual Studio 设置文件损坏/MySQL 连接问题

mysql - 哪种数据库引擎适合大数据集

php - 刷新时重新发送表单

javascript - 如何将数据从 Node.js(webpack) 发送到纯 Node.js(express)?

php - 设置每节动态数据集的 mysql 查询

php - PHP 中的 Mysqli 资源作为参数或全局