我有一个 txt 文件,它像 rss 一样每 5 分钟更新一次值。我用 curl 记录值,它会自动插入到 Mysql 中。
但有一个问题。在 txt 文件中,当我记录新行时,它会用旧行插入它们。
要插入的 PHP 行。
$addvalue = "INSERT INTO city SET cities='$cities', date='$date'";
mysql_query($addvalue)
Mysql 行
INSERT INTO `city` VALUES (1, 'ISTANBUL', '2013-06-19 18:09:39');
INSERT INTO `city` VALUES (2, 'IZMIR', '2013-06-19 15:06:35');
INSERT INTO `city` VALUES (3, 'LONDON', '2013-06-19 11:17:15');
INSERT INTO `city` VALUES (4, 'BERLIN', '2013-06-18 06:12:21');
有了新线,它会再次保存旧线
INSERT INTO `city` VALUES (1, 'ISTANBUL', '2013-06-19 18:09:39');
INSERT INTO `city` VALUES (2, 'IZMIR', '2013-06-19 15:06:35');
INSERT INTO `city` VALUES (3, 'LONDON', '2013-06-19 11:17:15');
INSERT INTO `city` VALUES (4, 'BERLIN', '2013-06-18 06:12:21');
INSERT INTO `city` VALUES (1, 'ISTANBUL', '2013-06-19 18:09:39');
INSERT INTO `city` VALUES (2, 'IZMIR', '2013-06-19 15:06:35');
INSERT INTO `city` VALUES (3, 'LONDON', '2013-06-19 11:17:15');
INSERT INTO `city` VALUES (4, 'BERLIN', '2013-06-18 06:12:21');
INSERT INTO `city` VALUES (5, 'MOSCOW', '2013-06-20 19:15:33');
INSERT INTO `city` VALUES (6, 'PARIS', '2013-06-20 12:18:32');
INSERT INTO `city` VALUES (7, 'NEW YORK', '2013-06-20 21:17:25');
INSERT INTO `city` VALUES (8, 'OSLO', '2013-06-20 07:17:44');
我试着像那样拯救他们
INSERT INTO `city` VALUES (1, 'ISTANBUL', '2013-06-19 18:09:39');
INSERT INTO `city` VALUES (2, 'IZMIR', '2013-06-19 15:06:35');
INSERT INTO `city` VALUES (3, 'LONDON', '2013-06-19 11:17:15');
INSERT INTO `city` VALUES (4, 'BERLIN', '2013-06-18 06:12:21');
INSERT INTO `city` VALUES (5, 'MOSCOW', '2013-06-20 19:15:33');
INSERT INTO `city` VALUES (6, 'PARIS', '2013-06-20 12:18:32');
INSERT INTO `city` VALUES (7, 'NEW YORK', '2013-06-20 21:17:25');
INSERT INTO `city` VALUES (8, 'OSLO', '2013-06-20 07:17:44');
我不想在 txt 中保存相同的旧行。当新行出现时,它应该添加到旧行的 mysql 底部。我该怎么做?