我正在使用下面的代码来从xml文件更新数据库,一切都按预期工作,但现在我不得不向表中添加更多的字段并通过html表单手动更新数据。PHP INSERT ON DUPLICATE KEY IGNORE添加空值?
当我运行窗体时,我可以将数据插入到“afk”和“备注”字段中,但在运行以下查询时,它将清空这些字段。
$insert = "INSERT INTO `ecmt_memberlist` (characterID,name,startDateTime,baseID,base,title,logonDateTime,logoffDateTime,locationID,location,shipTypeID,shipType,roles,grantableRoles, last_modified) VALUES('$characterID','$name','$startDateTime','$baseID','$base','$title','$logonDateTime','$logoffDateTime','$locationID','$location','$shipTypeID','$shipType','$roles','$grantableRoles','$modifiedTS') ON DUPLICATE KEY UPDATE
name='$name',
startDateTime='$startDateTime',
baseID='$baseID',
base='$base',
title='$title',
logonDateTime='$logonDateTime',
logoffDateTime='$logoffDateTime',
locationID='$locationID',
location='$location',
shipTypeID='$shipTypeID',
shipType='$shipType',
roles='$roles',
grantableRoles='$grantableRoles',
last_modified = '$modifiedTS'";
是否有可能告诉查询忽略已存储在额外2个手动字段中的值并保持数据完好?
千恩万谢
检查'插入忽略':http://stackoverflow.com/questions/2366813/on-duplicate-key-ignore – complex857 2013-02-19 20:47:57