开发者

How do I write an if statement that checks for duplicate database entries?

How do I write an if statement in PHP that checks a database for $varialbe and have it only pe开发者_运维问答rform the action if $varialbe is not already in the database?


You can count number of items in database by SELECT count(*) FROM table WHERE field=? query, and then insert record if there is no such records.

You can also add UNIQUE index to the table column you want to have only unique values


if (! DBA::RowExists("select 1 from table where key = '$varialbe'"))
{
 ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜