public function insert($collectionName, $document, $options = [])
    {
        $this->document = [];
        $this->addInsert($document);
        $result = $this->executeBatch($collectionName, $options);

        if ($result['result']->getInsertedCount() < 1) {
            return false;
        }

        return reset($result['insertedIds']);
    }
public function insert($collectionName, $document, $options = [])
    {
        $this->document = [];
        $this->addInsert($document);
        $result = $this->executeBatch($collectionName, $options);

        if ($result['result']->getInsertedCount() < 1) {
            return false;
        }

        return reset($result['insertedIds']);
    }
public function insert ( $ collectionName , $ document , $ options = [ ] ) { $ this -> document = [ ] ; $ this -> addInsert ( $ document ) ; $ result = $ this -> executeBatch ( $ collectionName , $ options ) ; if ( $ result [ 'result' ] -> getInsertedCount ( ) < 1 ) { return false ; } return reset ( $ result [ 'insertedIds' ] ) ; }
Inserts new document into collection.
@param string $collectionName collection name
@param array $document document content
@param array $options list of options in format: optionName => optionValue.
@return ObjectID|bool inserted record ID, `false` - on failure.
Inserts new document into collection .