PDO插入两次

时间:2016-11-23 20:59:10

标签: php mysql pdo

我有一个简单的index.php用于测试目的,没有别的

的index.php

$db = new \PDO('mysql:host=localhost;dbname=test', 'root', 'root');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$db->exec('set names utf8');

$query = $db->prepare('INSERT INTO events(name, description) VALUES (?, ?)');
$query->execute(array('test', 'test2'));
exit;

在执行上面的代码之前我的表是干净的,并且对于每次刷新,我得到两个额外的行。

我过去曾使用过PDO,之前从未发生过这件事。我不知道它为什么插入两次。

有谁知道为什么?

0 个答案:

没有答案