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

php如何实现添加分类?

WBOY
Release: 2016-06-06 20:18:10
Original
1635 people have browsed it

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

回复内容:

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

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

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

3.replace
4.on duplicate key update

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template