我想检查一下,如果来自帖子$var
的值是否存在于表中,如果是,则给我消息存在n exit。如果没有,那么插入表
$qry = "SELECT * FROM nl_lang_var where name='$var'";
$res =$GLOBALS['DB']->execute($qry);
if(mysql_num_rows($res)> 0)
{
echo "already existed";
exit;}
else {
$sql = "INSERT INTO nl_lang_var set value='$value' , name='$var' and langid=$langid"; }
答案 0 :(得分:0)
用户在mysql Ref
中插入IGNOREINSERT IGNORE INTO mytable
(primaryKey, field1, field2)
VALUES
('abc', 1, 2);