Commit 150639e4 authored by platyhouse's avatar platyhouse

# MySQL 백업 스크립트 테이블 패턴 매칭 기능 개선

## ptyMysqlBackup

### 와일드카드 패턴 매칭 개선
- ptyMysqlBackup: 테이블 패턴 검사를 단순 `*` 일치에서 `strpos($tablePattern, '*') !== false`로 변경하여 부분 와일드카드 패턴도 지원
- ptyMysqlBackup: `fnmatch()` 함수를 사용하여 `*`, `?` 와일드카드 패턴 매칭 구현
- ptyMysqlBackup: 패턴에 매칭되는 테이블이 없을 경우 스킵 메시지 출력 및 다음 데이터베이스로 진행
- ptyMysqlBackup: PHP 5.6 호환성을 위해 `[]` 배열 문법을 `array()`로 변경
parent 02798b25
...@@ -256,19 +256,29 @@ try { ...@@ -256,19 +256,29 @@ try {
echo str_repeat("-", 40) . "\n"; echo str_repeat("-", 40) . "\n";
// 테이블 목록 조회 // 테이블 목록 조회
if ($tablePattern === '*') { if (strpos($tablePattern, '*') !== false) {
// 와일드카드 패턴이 있으면 전체 테이블 조회 후 필터링
$tableResult = mysqli_query($connection, "SHOW TABLES FROM `$dbName`"); $tableResult = mysqli_query($connection, "SHOW TABLES FROM `$dbName`");
if (!$tableResult) { if (!$tableResult) {
logMessage("ERROR: $dbName 테이블 조회 실패", true); logMessage("ERROR: $dbName 테이블 조회 실패", true);
continue; continue;
} }
$tables = []; $tables = array();
while ($row = mysqli_fetch_row($tableResult)) { while ($row = mysqli_fetch_row($tableResult)) {
$tables[] = $row[0]; $tableName = $row[0];
// fnmatch로 패턴 매칭 (*, ? 지원)
if (fnmatch($tablePattern, $tableName)) {
$tables[] = $tableName;
}
}
if (empty($tables)) {
logMessage("SKIP: $dbName - 패턴 '$tablePattern'에 맞는 테이블 없음", true);
continue;
} }
} else { } else {
$tables = [$tablePattern]; $tables = array($tablePattern);
} }
foreach ($tables as $tableName) { foreach ($tables as $tableName) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment