Home > Backend Development > PHP Tutorial > mysql中怎么把insert和update写成一个函数以便多次调用?

mysql中怎么把insert和update写成一个函数以便多次调用?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:22:41
Original
1334 people have browsed it

目的是多次调用并提高代码质量。注意:此处不同于类的封装。

回复内容:

目的是多次调用并提高代码质量。注意:此处不同于类的封装。

prepare statement或者stored procedure

使用insert on duplicate key
INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;
http://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html

Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template