My application is not alerting me to a failed insert when adding a record to a MongoDB collection with a unique index…
$dm->flush()
… does not complain. I’m trying to figure out what the array parameter to flush should look like to see if that helps but getting nowhere. flush does not return anything on success or failure.
Any ideas on how I can verify, in my PHP/Symfony2 application, whether the insert worked without needing to query the db immediately after inserting?
Got it. Per this link, must provide
array("safe" => true)as a parameter to the write operation.So when using the code above and trying to insert into a unique index an exception will be thrown.