How to insert point data into mysql using PDO bindParam?

后端 未结 2 1452
孤城傲影
孤城傲影 2020-12-19 20:50

DETAILS

I\'d like to make use of mysql\'s spatial extension, so I am trying to store longitude and latitude in a mysql table of datatype POINT using

2条回答
  •  半阙折子戏
    2020-12-19 21:27

    Note that parameterizing queries is not (simple) string replacement. In your code your query parameter is put in a string literal which will be kept untouched.

    Try this:

    $location = 'POINT(' . $latitude . " " . $longitude . ')';
    $sql = "INSERT INTO my_geodata SET location = PointFromText(:location)";
    

提交回复
热议问题