Skip to content

I dont understand how to use types method #4

@solovichenko

Description

@solovichenko

I write this for have available use types in bulk insert:

private function types(array $types, int $datasetLength, array $columns): array
    {
        $positionalTypes = [];

        for ($dataRowIdx = 0; $dataRowIdx < $datasetLength; $dataRowIdx++) {
            foreach (array_values($columns) as $columnIndex => $column) {
                $columnIndex = $columnIndex + $dataRowIdx * count($columns);
                $positionalTypes[$columnIndex] = null;
                if (array_key_exists($column, $types)) {
                    $positionalTypes[$columnIndex] = $types[$column];
                }
            }
        }

        return $positionalTypes;
    }

And

return $this->connection->executeUpdate($sql, $this->parameters($dataset), $this->types($types, count($dataset), $this->extractColumns($dataset)));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions