调用以下函数插入后,lastinsertid返回数字每次都+1,但表就是空的。在数据库管理页面上直接添加一行,也发现id是增加了的。
function insert_del($operator='insert', $openid) {
global $pdo;
if ($operator='insert') {
$sql = "insert openid (openid, voilate_times, timestamp) values (:openid, :voilate_times, :timestamp)";
$sth = $pdo->prepare($sql);
$sth->execute(['openid'=>$openid, 'voilate_times'=>1, 'timestamp'=>time()]);
echo $pdo->lastInsertId();
}
if ($operator='del') {
$sql = "delete from openid where openid=:openid";
$sth = $pdo->prepare($sql);
$sth->execute(['openid'=>$openid]);
}
$pdo = null;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…