我正在使用下面的代碼來從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