Reputation:
How can I check to see if there was an error with MongoDB?
var_dump($mongodb->lastError());
gives me a blank page.
Upvotes: 1
Views: 4113
Reputation: 9313
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());
Upvotes: 1