MongoDB::lastError
Check if there was an error on the most recent db operation performed
&reftitle.description;
public arrayMongoDB::lastError
This method is equivalent to:
command(array('getlasterror' => 1));
}
?>
]]>
&reftitle.parameters;
&no.function.parameters;
&reftitle.returnvalues;
Returns the error, if there was one.
&reftitle.examples;
MongoDB::lastError &null; error example
resetError();
var_dump($db->lastError());
?>
]]>
&example.outputs.similar;
NULL
["n"]=>
int(0)
["ok"]=>
float(1)
}
]]>
MongoDB::lastError duplicate key example
selectCollection("foo");
// insert two documents with the same _id
$c->insert(array("_id" => 1));
$c->insert(array("_id" => 1));
var_dump($db->lastError());
?>
]]>
&example.outputs.similar;
string(64) "E11000 duplicate key errorindex: foo.foo.$_id_ dup key: { : 1 }"
["n"]=>
int(0)
["ok"]=>
float(1)
}
]]>