我正在尝试使用LOAD DATA LOCAL INFILE
将大型gpx文件导入mysql。
问题:
LAT
和LON
的值未写在表中,其余的已经写在表中。
我的问题是:
如何处理值LAT
和LON
,以便它们也写入表中?
非常感谢
gpx跟踪示例:
...
<gpx>
<trk>
<trkseg>
<trkpt lat="53.549945" lon="10.025673">
<ele>39.100000</ele>
<time>2019-03-20T01:39:59.000Z</time>
<fix>3d</fix>
</trkpt>
<trkpt lat="53.549932" lon="10.025675">
<ele>38.600000</ele>
<time>2019-03-20T01:40:00.000Z</time>
<fix>3d</fix>
</trkpt>
<trkpt lat="53.549925" lon="10.025682">
<ele>38.500000</ele>
<time>2019-03-20T01:40:01.000Z</time>
<fix>3d</fix>
</trkpt>
</trkseg>
</trk>
</gpx>
...
这是我的MySql查询,用于插入数据:
$this->db->query("
LOAD DATA LOCAL INFILE '" . $files['gpx']['tmp_name'] . "'
INTO TABLE `track`
CHARACTER SET 'utf8'
LINES STARTING BY '<trkseg>' TERMINATED BY '</trkseg>'
(@tmp)
SET
lat = ExtractValue(@tmp, '//lat'),
lon = ExtractValue(@tmp, '//lon'),
ele = ExtractValue(@tmp, '//ele'),
time = ExtractValue(@tmp, '//time'),
fix = ExtractValue(@tmp, '//fix')
");