Y
Y
yaNitik2015-08-23 18:28:05
PHP
yaNitik, 2015-08-23 18:28:05

Why does MongoDB 3.0 throw an error when trying to get records?

<?php
$m = new MongoClient(); // соединение
$db = $m->test; 
$db->shows->insert( ["item" => "card", "qty" => 15] );
  echo $a = $db->shows->find();
?>

Catchable fatal error: Object of class MongoCursor could not be converted to string in /var/www/html/index.php on line 14

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lega, 2015-08-23
@yaNitik

Apparently the cursor needs to be sorted out in a loop, or at least converted to an array before displaying.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question