src/Query/Runner.php
public function insert(array $values)
    {
        // Since every insert gets treated like a batch insert, we will have to detect
        // if the user is inserting a single document or an array of documents.
        $batch = true;

        foreach ($values as $value) {
            // As soon as we find a value that is not an array we assume the user is
            // inserting a single document.
            if (!is_array($value)) {
                $batch = false;
                break;
            }
        }

        if (!$batch) {
            $values = [$values];
        }

        // Batch insert
        $result = $this->collection->insertMany($values);

        return (1 == (int) $result->isAcknowledged());
    }
public function insert(array $values)
    {
        // Since every insert gets treated like a batch insert, we will have to detect
        // if the user is inserting a single document or an array of documents.
        $batch = true;

        foreach ($values as $value) {
            // As soon as we find a value that is not an array we assume the user is
            // inserting a single document.
            if (!is_array($value)) {
                $batch = false;
                break;
            }
        }

        if (!$batch) {
            $values = [$values];
        }

        // Batch insert
        $result = $this->collection->insertMany($values);

        return (1 == (int) $result->isAcknowledged());
    }
public function insert ( array $ values ) { // Since every insert gets treated like a batch insert, we will have to detect // if the user is inserting a single document or an array of documents. $ batch = true ; foreach ( $ values as $ value ) { // As soon as we find a value that is not an array we assume the user is // inserting a single document. if ( ! is_array ( $ value ) ) { $ batch = false ; break ; } } if ( ! $ batch ) { $ values = [ $ values ] ; } // Batch insert $ result = $ this -> collection -> insertMany ( $ values ) ; return ( 1 == ( int ) $ result -> isAcknowledged ( ) ) ; }
Insert documents.

@param array $values
@return bool
Insert documents .