public function insert(&$a, array $options = [])
{
if (!$this->ensureDocumentHasMongoId($a)) {
trigger_error(sprintf('%s(): expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING);
return;
}
if (!count((array) $a)) {
throw new \MongoException('document must be an array or object');
}
try {
$result = $this->collection->insertOne(TypeConverter::fromLegacy($a), $this->convertWriteConcernOptions($options));
} catch (\MongoDB\Driver\Exception\Exception $e) {
throw ExceptionConverter::toLegacy($e);
}
if (!$result->isAcknowledged()) {
return true;
}
return ['ok' => 1.0, 'n' => 0, 'err' => null, 'errmsg' => null];
}