public static function prepareMultiInsertOrUpdate(string $table, array $rows, array $ignoreForUpdate = []): array
    {
        $columns = static::extractColumnsFromRows($rows);
        $columns = static::escapeSqlWords($columns);
        $ignoreForUpdate = static::escapeSqlWords($ignoreForUpdate);

        /**
         * since PHP 7.1 this can look like:
         * ['params' => $params, 'valueParts' => $valueParts] = static::generateMultiParams($rows, $columns)
         */
        [$params, $valueParts] = array_values(static::generateMultiParams($rows, $columns));

        $sql = 'INSERT INTO ' . static::escapeSqlWords($table);
        $sql .= ' (' . implode(', ', $columns) . ')';
        $sql .= ' VALUES ';
        $sql .= implode(', ', $valueParts);
        $sql .= ' ON DUPLICATE KEY UPDATE ';

        $updateArray = [];
        foreach ($columns as $col) {
            if (! in_array($col, $ignoreForUpdate, true)) {
                $updateArray[] = "${col}=VALUES(${col})";
            }
        }
        $sql .= implode(', ', $updateArray);

        return [
            'sql' => $sql,
            'params' => $params,
        ];
    }