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;
        }

        $this->mustBeArrayOrObject($a);

        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,
        ];
    }
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;
        }

        $this->mustBeArrayOrObject($a);

        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,
        ];
    }
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 ; } $ this -> mustBeArrayOrObject ( $ a ) ; 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 , ] ; }
Inserts an array into the collection

@link http://www.php.net/manual/en/mongocollection.insert.php
@param array|object $a
@param array $options
@throws MongoException if the inserted document is empty or if it contains zero-length keys. Attempting to insert an object with protected and private properties will cause a zero-length key error.
@throws MongoCursorException if the "w" option is set and the write fails.
@throws MongoCursorTimeoutException if the "w" option is set to a value greater than one and the operation takes longer than MongoCursor::$timeout milliseconds to complete. This does not kill the operation on the server, it is a client-side timeout. The operation in MongoCollection::$wtimeout is milliseconds.
@return bool|array Returns an array containing the status of the insertion if the "w" option is set.
Inserts an array into the collection