src/EasyDB.php
public function insertMany(string $table, array $maps): int
    {
        if (count($maps) < 1) {
            throw new \InvalidArgumentException(
                'Argument 2 passed to ' .
                    static::class .
                '::' .
                    __METHOD__ .
                '() must contain at least one field set!'
            );
        }
        /**
         * @var array $first
         */
        $first = $maps[0];
        /**
         * @var array $map
         */
        foreach ($maps as $map) {
            if (!$this->is1DArray($map)) {
                throw new Issues\MustBeOneDimensionalArray(
                    'Every map in the second argument should have the same number of columns.'
                );
            }
        }

        $queryString = $this->buildInsertQuery($table, \array_keys($first));

        // Now let's run a query with the parameters
        $stmt = $this->prepare($queryString);
        $count = 0;
        /**
         * @var array $params
         */
        foreach ($maps as $params) {
            $stmt->execute(\array_values($params));
            $count += $stmt->rowCount();
        }
        return $count;
    }
public function insertMany(string $table, array $maps): int
    {
        if (count($maps) < 1) {
            throw new \InvalidArgumentException(
                'Argument 2 passed to ' .
                    static::class .
                '::' .
                    __METHOD__ .
                '() must contain at least one field set!'
            );
        }
        /**
         * @var array $first
         */
        $first = $maps[0];
        /**
         * @var array $map
         */
        foreach ($maps as $map) {
            if (!$this->is1DArray($map)) {
                throw new Issues\MustBeOneDimensionalArray(
                    'Every map in the second argument should have the same number of columns.'
                );
            }
        }

        $queryString = $this->buildInsertQuery($table, \array_keys($first));

        // Now let's run a query with the parameters
        $stmt = $this->prepare($queryString);
        $count = 0;
        /**
         * @var array $params
         */
        foreach ($maps as $params) {
            $stmt->execute(\array_values($params));
            $count += $stmt->rowCount();
        }
        return $count;
    }
public function insertMany ( string $ table , array $ maps ) : int { if ( count ( $ maps ) < 1 ) { throw new \ InvalidArgumentException ( 'Argument 2 passed to ' . static :: class . '::' . __METHOD__ . '() must contain at least one field set!' ) ; } /**
         * @var array $first
         */ $ first = $ maps [ 0 ] ; /**
         * @var array $map
         */ foreach ( $ maps as $ map ) { if ( ! $ this -> is1DArray ( $ map ) ) { throw new Issues \ MustBeOneDimensionalArray ( 'Every map in the second argument should have the same number of columns.' ) ; } } $ queryString = $ this -> buildInsertQuery ( $ table , \ array_keys ( $ first ) ) ; // Now let's run a query with the parameters $ stmt = $ this -> prepare ( $ queryString ) ; $ count = 0 ; /**
         * @var array $params
         */ foreach ( $ maps as $ params ) { $ stmt -> execute ( \ array_values ( $ params ) ) ; $ count += $ stmt -> rowCount ( ) ; } return $ count ; }
Insert many new rows to a table in a database. using the same prepared statement

@param          string $table - table name
@param          array  $maps  - array of associative array specifying values should be assigned to each field
@return         int
@throws         \InvalidArgumentException
@throws         Issues\QueryError
@psalm-suppress MixedAssignment
@psalm-suppress MixedArgument
Insert many new rows to a table in a database . using the same prepared statement