PHP:在准备好的语句上获取插入确认
我是一位准备好陈述并尝试简单工作的新手。
这是我的数据库表格:
`unblocker_users` (
`uno` bigint(20) NOT NULL AUTO_INCREMENT,
`user_email` varchar(210) DEFAULT NULL,
`pw_hash` varchar(30) DEFAULT NULL,
`email_confirmed` tinyint(4) DEFAULT NULL,
`total_requests` bigint(20) DEFAULT NULL,
`today_date` date DEFAULT NULL,
`accessed_today` tinyint(4) DEFAULT NULL,)
这是我的功能插入一些测试数据
function add_new_user($e_mail1)
{
require_once "db.php";
$stmt = $mysqli->prepare("INSERT INTO unblocker_users VALUES ('',?, ?,0,0,?,0)");
$stmt->bind_param('sss', $e_mail1, $this->genRandomString(1),$this->today_date());
$stmt->execute();
$stmt->close();
// ####### Below line is giving an error ########
$done = $stmt->affected_rows;
return $done;
}
正如你在上面看到的,我已经标记了给我一个错误的那一行。
Warning: unblocker_class::add_new_user() [unblocker-class.add-new-user]: Property access is not allowed yet in...
我哪里做错了? 我怎样才能得到某种确认已成功插入一行?
谢谢!
您要在访问其受影响的行之前关闭准备好的语句
$done = $stmt->affected_rows;
$stmt->close();
return $done;
链接地址: http://www.djcxy.com/p/44875.html
上一篇: PHP: Getting insert confirmation on prepared statement
下一篇: How to print out the real sql, not just the prepared statement?