Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit e07c4097 authored by 65160394's avatar 65160394
Browse files

Project Round 3

parent b78764b6
Branches
No related tags found
No related merge requests found
......@@ -14,19 +14,6 @@ class Tour {
}
}
// ดึงทัวร์ตาม ID
static async getTourById(id) {
try {
const [rows] = await pool.query('SELECT * FROM tours WHERE id = ?', [id]);
if (rows.length === 0) {
throw new Error('ไม่พบทัวร์ที่มี ID นี้');
}
return rows[0];
} catch (error) {
console.error('Error fetching tour by ID:', error);
throw new Error('เกิดข้อผิดพลาดในการดึงข้อมูลทัวร์');
}
}
// สร้างทัวร์
static async createTour(name, description, price, duration) {
......@@ -63,6 +50,21 @@ class Tour {
}
}
// ดึงทัวร์ตาม ID
static async getTourById(id) {
try {
console.log('Searching for tour with ID:', id); // เพิ่มบรรทัดนี้
const [rows] = await pool.query('SELECT * FROM tours WHERE id = ?', [id]);
if (rows.length === 0) {
throw new Error('ไม่พบทัวร์ที่มี ID นี้');
}
return rows[0];
} catch (error) {
console.error('Error fetching tour by ID:', error);
throw new Error('เกิดข้อผิดพลาดในการดึงข้อมูลทัวร์');
}
}
// ลบทัวร์
static async deleteTour(id) {
const query = 'DELETE FROM tours WHERE id = ?';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment