728x90
db스크립트에
public void UpdateTableMultiple(
string tableName,
Dictionary<string, object> updates,
string whereColumn,
object whereValue
)
{
if (updates == null || updates.Count == 0) return;
List<string> setClauses = new List<string>();
List<object> paramValues = new List<object>();
int idx = 0;
foreach (var kvp in updates)
{
string paramName = "@val" + idx;
setClauses.Add($"{kvp.Key} = {paramName}");
paramValues.Add(kvp.Value);
idx++;
}
string setClause = string.Join(", ", setClauses);
string query = $"UPDATE {tableName} SET {setClause} WHERE {whereColumn} = @whereVal";
paramValues.Add(whereValue); // 조건 값 추가
dbM.Execute(query, paramValues.ToArray());
}
이렇게 하고
사용하는 방법은
Dictionary<string, object> updates = new Dictionary<string, object>()
{
{ "author", "생택쥐페리" },
{ "category", "novel" },
{ "createdDate", "2025-10-05" }
};
QueryManager.instance.UpdateTableMultiple("Book", updates, "b_idx", "book_001");
이렇게.
'Unity' 카테고리의 다른 글
| [ Unity ] 갑자기 The type or namespace name 'Steamworks' could not be found (0) | 2025.09.28 |
|---|---|
| [ Unity ] 유니티 오브젝트 Missing 스크립트 찾기(with GIT) (0) | 2025.06.14 |
| [ Unity ] IOS 포커스 잃었을 때, 화면 가리기 (1) | 2025.02.15 |
| [ Unity ] scrollbar 위, 아래로 내리기. value 숫자 범위 0~1 아닐때 (0) | 2025.02.06 |
| [ Unity ] 해상도 조절 후 뒷배경 잔상. 레터박스 잔상과 플리커 현상 (0) | 2025.01.26 |