如何在MySQLi中使用POINT MySQL类型-PHP [英] How to use POINT mysql type with mysqli - php

查看:91
本文介绍了如何在MySQLi中使用POINT MySQL类型-PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于PHP .net中的此表:

Based on this table from 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

我写代码:

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

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

but problem is becouse my startLocation field in database use type POINT, so

如何在MySQL中使用POINT dataType进行bind_param?

How I can make bind_param with POINT dataType in mysql?

推荐答案

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

You should use MYSQL function POINT in order to convert from Latitude/Longitude

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

这篇关于如何在MySQLi中使用POINT MySQL类型-PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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