public function addInsert(array $rows): self
    {
        if (!empty($rows) && !is_array(reset($rows))) {
            $rows = [$rows];
        }

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

            $filteredRow = [];

            foreach ($row as $column => $value) {
                if (!is_string($column)) {
                    return $this->handleException(InvalidArgumentException::create(
                        'The argument $rows['.$index.'] indexes',
                        $column,
                        ['string']
                    ));
                }

                $value = $this->checkScalarOrNullValue('Argument $rows['.$index.']['.$column.']', $value);
                $filteredRow[$column] = $value;
            }

            $this->insert[] = $filteredRow;
        }

        return $this;
    }
public function addInsert(array $rows): self
    {
        if (!empty($rows) && !is_array(reset($rows))) {
            $rows = [$rows];
        }

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

            $filteredRow = [];

            foreach ($row as $column => $value) {
                if (!is_string($column)) {
                    return $this->handleException(InvalidArgumentException::create(
                        'The argument $rows['.$index.'] indexes',
                        $column,
                        ['string']
                    ));
                }

                $value = $this->checkScalarOrNullValue('Argument $rows['.$index.']['.$column.']', $value);
                $filteredRow[$column] = $value;
            }

            $this->insert[] = $filteredRow;
        }

        return $this;
    }
public function addInsert ( array $ rows ) : self { if ( ! empty ( $ rows ) && ! is_array ( reset ( $ rows ) ) ) { $ rows = [ $ rows ] ; } foreach ( $ rows as $ index => $ row ) { if ( ! is_array ( $ row ) ) { return $ this -> handleException ( InvalidArgumentException :: create ( 'Argument $rows[' . $ index . ']' , $ row , [ 'array' ] ) ) ; } $ filteredRow = [ ] ; foreach ( $ row as $ column => $ value ) { if ( ! is_string ( $ column ) ) { return $ this -> handleException ( InvalidArgumentException :: create ( 'The argument $rows[' . $ index . '] indexes' , $ column , [ 'string' ] ) ) ; } $ value = $ this -> checkScalarOrNullValue ( 'Argument $rows[' . $ index . '][' . $ column . ']' , $ value ) ; $ filteredRow [ $ column ] = $ value ; } $ this -> insert [ ] = $ filteredRow ; } return $ this ; }
Adds a row to insert to the table.

Warning, calling this method removes a given insert from select.

@param mixed[][]|\Closure[][]|Query[][]|StatementInterface[][]|mixed[]|\Closure[]|Query[]|StatementInterface[] $rows
A row or an array of rows. Each row is an associative array where indexes are column names and values are
cell values. Rows indexes must be strings.
@return $this
@throws InvalidArgumentException
@throws InvalidReturnValueException
Adds a row to insert to the table .