发布数据时检查数据库是否已经存在 [ php、mysql ]
下面的代码是发布数据,请问如何增加发布时检测数据库中是否已经存在相同的数据 ($iname),如有,将已有的数据更新时间变成最新就好! ( $iupdatetime )
==================================================
if($_G['gp_mod'] == 'add' && in_array($_G['uid'], $admins)){
if(!submitcheck('addsubmit')){
include template('drc_news:add');
}else{
$iname = dhtmlspecialchars($_G['gp_iname']);
$iupdatetime = empty($_G['gp_iupdatetime']) ? TIMESTAMP : strtotime($_G['gp_iupdatetime']);
DB::insert('drc_news', array('iname' => $iname, 'iupdatetime' => $iupdatetime));
showmessage(lang('plugin/drc_news', 'add_acc'), 'plugin.php?id=drc_news:main', array(), array('locationtime'=>2, 'showdialog'=>1, 'showmsg' => true, 'closetime' => 2));
}
追问:麻烦代为修改代码。本人超级小白,不知道怎么判断、加在哪里呢?