add isNumericType() и convertNumericFormat()
This commit is contained in:
@@ -544,7 +544,51 @@ private function formatRowData(array $rowData): string
|
||||
// Если не удалось распарсить - возвращаем как есть
|
||||
return $date;
|
||||
}
|
||||
// ✅ ДОБАВЬТЕ ЭТИ ДВА МЕТОДА СЮДА:
|
||||
|
||||
private function isNumericType(string $dataType): bool
|
||||
{
|
||||
$numericTypes = [
|
||||
'int', 'tinyint', 'smallint', 'mediumint', 'bigint',
|
||||
'decimal', 'float', 'double', 'numeric', 'real'
|
||||
];
|
||||
|
||||
$dataType = strtolower($dataType);
|
||||
|
||||
foreach ($numericTypes as $type) {
|
||||
if (str_contains($dataType, $type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function convertNumericFormat($value)
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = trim((string)$value);
|
||||
$value = str_replace(' ', '', $value);
|
||||
|
||||
if (strpos($value, ',') === false) {
|
||||
return is_numeric($value) ? $value : null;
|
||||
}
|
||||
|
||||
$lastCommaPos = strrpos($value, ',');
|
||||
$lastDotPos = strrpos($value, '.');
|
||||
|
||||
if ($lastCommaPos > $lastDotPos) {
|
||||
$value = str_replace('.', '', $value);
|
||||
$value = str_replace(',', '.', $value);
|
||||
} else {
|
||||
$value = str_replace(',', '', $value);
|
||||
}
|
||||
|
||||
return is_numeric($value) ? $value : null;
|
||||
}
|
||||
public function exportCSV(
|
||||
string $schema,
|
||||
string $table,
|
||||
|
||||
Reference in New Issue
Block a user