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

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

WBOY
WBOYOriginal
2016-06-02 11:32:061189browse

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'));

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

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