Home > Backend Development > PHP Tutorial > pdo-PDO execute()插入数据总是重复两条是什么情况?

pdo-PDO execute()插入数据总是重复两条是什么情况?

WBOY
Release: 2016-06-02 11:32:06
Original
1235 people have browsed it

pdophp

$db = new PDO('mysql:host=localhost;dbname=db;charset=utf8', 'root', 'root');
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$db->query('SET NAMES UTF8');
$sth = $db->prepare("INSERT INTO table (id, name) VALUES (NULL, ?)");
$sth->execute(array('name'));

使用上述代码可以成功插入数据,但是运行后每次插入的数据都是两条重复的,请求各位达人帮解小弟疑惑 - -

Related labels:
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