使用准备好的语句更新查询
遇到问题并更新查询时,我不断收到
Warning: Crud::update() [crud.update]: Property access is not allowed yet in crud.php on line 60
这是我的代码
$stmt = $this->mysql->prepare('UPDATE links SET title = ?, url = ?, comment = ? WHERE id = ?');
$stmt->bind_param('sssi',$title,$url,$comment,$id);
$stmt->execute();
$stmt->close();
on line 60 return $stmt->affected_rows;
Google 搜索它,只在评论中的 php 文档中找到了一个引用,但我无法理解该评论:/
Having problems with and update query i keep getting
Warning: Crud::update() [crud.update]: Property access is not allowed yet in crud.php on line 60
This is my code
$stmt = $this->mysql->prepare('UPDATE links SET title = ?, url = ?, comment = ? WHERE id = ?');
$stmt->bind_param('sssi',$title,$url,$comment,$id);
$stmt->execute();
$stmt->close();
on line 60 return $stmt->affected_rows;
Googled it and only found one reference in the php documentation in a comment but i couldn't understand the comment :/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您确定该陈述返回 true 吗?根据 php 文档,如果语句准备不正确或根本没有准备好,就会发生此错误。
“为了防止这种情况发生,请在访问这些属性之前始终确保“prepare”语句的返回值为 true。”
希望这有帮助
干杯
are you sure the stament returns true? this error occurs if the statement was not prepared properly, or not prepared at all, according to php documentation.
"To prevent this, always ensure that the return value of the "prepare" statement is true before accessing these properties."
Hope this helps
cheers
你想要
vs
吗?
我不知道。
否则,您可以先检查以确认不存在 mysql 错误,然后再检查受影响的行。
Do you want
vs.
?
I'm not sure.
Otherwise you can check to confirm that there was no mysql error first before checking the affected rows.
问题是我在使用
$stmt->affected_rows;
之前确实使用了$stmt->close();
愚蠢的错误。这就是我深夜编码得到的结果。The problem was that I used
$stmt->close();
before using$stmt->affected_rows;
silly error really. That's what I get for late night coding.