php - 可捕获的致命错误:无法将 PDOStatement 类的对象转换为第 40 行 D:\wamp64\www\blog\modal\CommentManager.php 中的字符串
问题描述
$bdd=$this->dbConnect();
$comment=$bdd->prepare('UPDATE commentaires SET commentaire=? WHERE id=? ');
$comment->execute(array($comment,$idComment));
$comment->fetch();
return $comment;
更新不起作用:此代码给我一个错误execute()
:
可捕获的致命错误:无法将 PDOStatement 类的对象转换为第 40 行 D:\wamp64\www\blog\modal\CommentManager.php 中的字符串
解决方案
您将$comment
用作变量PDOStatement
并再次用作第一个输入参数的值。
更改(array($comment, $idComment)
为(array($textComment, $idComment)
:
<?php
$bdd = $this->dbConnect();
$comment = $bdd->prepare('UPDATE commentaires SET commentaire=? WHERE id=? ');
$comment->execute(array($textComment, $idComment));
$comment->fetch();
return $comment;
?>
推荐阅读
- php - Wordpress 页面内容和帖子在同一页面中
- javafx - JavaFX Raspberry WiFi 搜索器
- windows - 无法打开acer switch 10;黑屏
- java - 当手指移过按钮时在 logcat 中显示文本
- gradle - Gradle Kotlin allprojects 依赖导致构建失败
- php - 正则表达式匹配我不想再匹配的东西
- wordpress - Wordpress 不显示超过 2 天的帖子
- c# - WPF MVVM 与 Razor 页面 MVVM
- redis - Spring Boot 微服务未与 Redis 通信
- python - 熊猫在字典列上分组,没有值