1

How can I check to see if there was an error with MongoDB?

var_dump($mongodb->lastError());

gives me a blank page.

SomeKittens
  • 38,868
  • 19
  • 114
  • 143

1 Answers1

1

Mongo::lastError — Check if there was an error on the most recent db operation performed

Deprecated

// NOT WORK!!
$mongo = new Mongo();
var_dump($mongo->lastError());

You only see a blank page because you have error reporting turned off in your PHP configuration.


MongoDB::lastError — Check if there was an error on the most recent db operation performed

You need MongoDB class

// WORK!!
$mongo = new Mongo();
$db    = $mongo->database;
var_dump($db->lastError());
Wahyu Kristianto
  • 8,719
  • 6
  • 43
  • 68