Home >Backend Development >PHP Tutorial >php如何实现添加分类?

php如何实现添加分类?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:18:101656browse

添加分类 如果数据库里已经有了的就不要添加 怎么实现?

回复内容:

添加分类 如果数据库里已经有了的就不要添加 怎么实现?

1.判断是否存在
2.唯一索引,INSERT IGNORE INTO

<code>INSERT IGNORE INTO `tablename` (key,...) VALUES(...)
</code>

3.replace
4.on duplicate key update

添加之前做个检测,如果有就return错误信息

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn