public function addInsertFromSelect($columns, $selectQuery = null): self
    {
        if ($selectQuery === null) {
            $selectQuery = $columns;
            $columns = null;
        }

        if ($columns !== null) {
            if (!is_array($columns)) {
                return $this->handleException(InvalidArgumentException::create(
                    'Argument $columns',
                    $columns,
                    ['array', 'null']
                ));
            }
            foreach ($columns as $index => $column) {
                if (!is_string($column)) {
                    return $this->handleException(InvalidArgumentException::create(
                        'Argument $columns['.$index.']',
                        $column,
                        ['string']
                    ));
                }
            }
        }

        $selectQuery = $this->checkSubQueryValue('Argument $selectQuery', $selectQuery);

        $this->insert[] = new InsertFromSelect($columns, $selectQuery);
        return $this;
    }
public function addInsertFromSelect($columns, $selectQuery = null): self
    {
        if ($selectQuery === null) {
            $selectQuery = $columns;
            $columns = null;
        }

        if ($columns !== null) {
            if (!is_array($columns)) {
                return $this->handleException(InvalidArgumentException::create(
                    'Argument $columns',
                    $columns,
                    ['array', 'null']
                ));
            }
            foreach ($columns as $index => $column) {
                if (!is_string($column)) {
                    return $this->handleException(InvalidArgumentException::create(
                        'Argument $columns['.$index.']',
                        $column,
                        ['string']
                    ));
                }
            }
        }

        $selectQuery = $this->checkSubQueryValue('Argument $selectQuery', $selectQuery);

        $this->insert[] = new InsertFromSelect($columns, $selectQuery);
        return $this;
    }
public function addInsertFromSelect ( $ columns , $ selectQuery = null ) : self { if ( $ selectQuery === null ) { $ selectQuery = $ columns ; $ columns = null ; } if ( $ columns !== null ) { if ( ! is_array ( $ columns ) ) { return $ this -> handleException ( InvalidArgumentException :: create ( 'Argument $columns' , $ columns , [ 'array' , 'null' ] ) ) ; } foreach ( $ columns as $ index => $ column ) { if ( ! is_string ( $ column ) ) { return $ this -> handleException ( InvalidArgumentException :: create ( 'Argument $columns[' . $ index . ']' , $ column , [ 'string' ] ) ) ; } } } $ selectQuery = $ this -> checkSubQueryValue ( 'Argument $selectQuery' , $ selectQuery ) ; $ this -> insert [ ] = new InsertFromSelect ( $ columns , $ selectQuery ) ; return $ this ; }
Adds an instruction that the query should insert values to the table from the select query.

Warning, calling this method removes all the rows set by the `insert` method.

@param string[]|\Closure|self|StatementInterface $columns The list of the columns to which the selected values
should be inserted. You may omit this argument and pass the $selectQuery argument instead.
@param \Closure|self|StatementInterface|null $selectQuery
@return $this
@throws InvalidArgumentException
@throws InvalidReturnValueException
Adds an instruction that the query should insert values to the table from the select query .