버튼에 제어 달기
This commit is contained in:
@@ -77,10 +77,17 @@ export class MSSQLConnector implements DatabaseConnector {
|
||||
}
|
||||
}
|
||||
|
||||
async executeQuery(query: string): Promise<QueryResult> {
|
||||
async executeQuery(query: string, params: any[] = []): Promise<QueryResult> {
|
||||
try {
|
||||
await this.connect();
|
||||
const result = await this.pool!.request().query(query);
|
||||
const request = this.pool!.request();
|
||||
|
||||
// 파라미터 바인딩 (SQL Server는 @param1, @param2 형식이지만 여기서는 ? 사용)
|
||||
params.forEach((param, index) => {
|
||||
request.input(`param${index + 1}`, param);
|
||||
});
|
||||
|
||||
const result = await request.query(query);
|
||||
return {
|
||||
rows: result.recordset,
|
||||
rowCount: result.rowsAffected[0],
|
||||
|
||||
@@ -61,13 +61,14 @@ export class MariaDBConnector implements DatabaseConnector {
|
||||
}
|
||||
}
|
||||
|
||||
async executeQuery(query: string): Promise<QueryResult> {
|
||||
async executeQuery(query: string, params: any[] = []): Promise<QueryResult> {
|
||||
try {
|
||||
await this.connect();
|
||||
const [rows, fields] = await this.connection!.query(query);
|
||||
const [rows, fields] = await this.connection!.query(query, params);
|
||||
await this.disconnect();
|
||||
return {
|
||||
rows: rows as any[],
|
||||
rowCount: Array.isArray(rows) ? rows.length : 0,
|
||||
fields: fields as any[],
|
||||
};
|
||||
} catch (error: any) {
|
||||
|
||||
@@ -76,13 +76,13 @@ export class MySQLConnector implements DatabaseConnector {
|
||||
}
|
||||
}
|
||||
|
||||
async executeQuery(query: string): Promise<QueryResult> {
|
||||
async executeQuery(query: string, params: any[] = []): Promise<QueryResult> {
|
||||
if (!this.connection) {
|
||||
await this.connect();
|
||||
}
|
||||
|
||||
try {
|
||||
const [rows, fields] = await this.connection!.query(query);
|
||||
const [rows, fields] = await this.connection!.query(query, params);
|
||||
return {
|
||||
rows: rows as any[],
|
||||
rowCount: Array.isArray(rows) ? rows.length : 0,
|
||||
|
||||
@@ -117,10 +117,10 @@ export class PostgreSQLConnector implements DatabaseConnector {
|
||||
}
|
||||
}
|
||||
|
||||
async executeQuery(query: string): Promise<QueryResult> {
|
||||
async executeQuery(query: string, params: any[] = []): Promise<QueryResult> {
|
||||
try {
|
||||
await this.connect();
|
||||
const result = await this.client!.query(query);
|
||||
const result = await this.client!.query(query, params);
|
||||
await this.disconnect();
|
||||
return {
|
||||
rows: result.rows,
|
||||
|
||||
Reference in New Issue
Block a user