可捕获的致命错误:无法将MongoCursor类的对象转换为字符串

Ausaf谢里夫

当我尝试查看MongoDB网页中的数据时,这是我的错误Wamp在Windows中使用

Catchable fatal error: Object of class MongoCursor could not be converted to string

这是什么意思,我该怎么办?

Ausaf谢里夫

我想出了消除错误的方法检查此代码

<?php
// connect to mongodb
$m = new MongoClient();

$db = $m->local;				// select a database
$collection = $db->directors;  // select a collection (table in old DB)
$cursor = $collection->find(); // view all
foreach ($cursor as $doc)
{
    var_dump($doc);
}
?>

在上面的代码中,该var_dump()函数用于显示值或变量的数据类型,因此,如果使用此函数,则在这种情况下还可以为您提供有关数据大小和长度的详细信息,并显示结果。

这段代码是关于如何从MongoDB获得价值并在PHP页面上显示的。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

可捕获的致命错误:无法将 AppBundle\Entity\Location 类的对象转换为字符串

Symfony 2可捕获的致命错误:无法将类UserCategory的对象转换为字符串

PHP,可捕获的致命错误:无法将mysqli类的对象转换为字符串

symfony2可捕获的致命错误:类的对象无法转换为字符串

可捕获的致命错误:DateTime类的对象无法转换为字符串

可捕获的致命错误:Instamojo类的对象无法转换为字符串

可捕获的致命错误:在行364中无法将类DateTime的对象转换为字符串

可捕获的致命错误:无法将类Proxies \ __ CG __ \ AppBundle \ Entity \ Ticket的对象转换为字符串

Symfony - 可捕获的致命错误:无法将类 App\Entity\Question 的对象转换为字符串

可捕获的致命错误:注册时无法将类mysqli_result的对象转换为字符串

可捕获的致命错误:无法转换为字符串?

可捕获的致命错误:mysqli_result类的对象无法在php中转换为字符串

Symfony 2.8可捕获的致命错误:类...的对象无法转换为字符串(一对多和多对一)

可恢复的致命错误:无法将 PDOStatement 类的对象转换为字符串

Symfony / Doctrine-Twig_Error_Runtime:可捕获的致命错误:Doctrine \ ORM \ PersistentCollection类的对象无法转换为字符串

可捕获的致命错误:在第30行的C:\ xampp \ htdocs \ testing.php中,类DateInterval的对象无法转换为字符串

PHP 致命错误:未捕获的错误:类 mcs_subdomain 的对象无法在 WordPress 中转换为字符串

可捕获的致命错误:类别WP_User的对象无法在第139行的/ directory /中转换为字符串

未捕获的错误:无法将类Core的对象转换为字符串

可捕获的致命错误:无法将PDO类的对象转换为

可恢复的致命错误:类 PDOStatement 的对象无法转换为字符串 PHP 错误消息

未捕获的错误:CompanyName 类的对象无法转换为字符串

URL转换无法将类stdClass的对象转换为字符串错误

无法将对象类转换为字符串错误

无法将类stdClass的对象转换为字符串

Doctrine:无法将类的对象转换为字符串

如何解决“可恢复的致命错误:类Closure的对象无法在...中转换为字符串”

插入查询结果为“可恢复的致命错误:mysqli 类的对象无法转换为字符串”

错误:无法将mysqli类的对象转换为字符串