How to use mysql POINT type with mysqli - php

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

I am writing the code:

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

      

but the problem is my startLocation field is in the database use type POINT

, so

How can I create bind_param with POINT dataType in mysql?

+3


source to share


1 answer


You have to use MYSQL POINT function to convert from latitude / longitude



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

      

0


source







All Articles