提交时检查数据是否已经存在

下面是提交数据的代码,请问如何增加发布时检测数据库中是否已经存在相同的数据 ($iname),如有,将已有的数据更新时间变成最新 ( $iupdatetime ) ,麻烦代为修改,感谢! 

PHP code

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));
        }

作者: lerio   发布时间: 2011-06-08

不如直接用insert + del,省去判断

作者: snmr_com   发布时间: 2011-06-08