Gitlab@Informatics

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

Project Round 8

parent f6f89c53
Branches
No related tags found
No related merge requests found
......@@ -58,23 +58,21 @@ class Tour {
// อัปเดตทัวร์
static async updateTour(id, tourData) {
static async updateTour(userId, tourData) {
const { name, description, price, duration } = tourData;
const query = 'UPDATE tours SET name = ?, description = ?, price = ?, duration = ? WHERE userId = ?';
// ตรวจสอบข้อมูล
if (!name || !price || !duration) {
throw new Error('ข้อมูลไม่ครบถ้วน กรุณากรอกข้อมูลให้ครบถ้วน');
}
const query = 'UPDATE tours SET name = ?, description = ?, price = ?, duration = ? WHERE id = ?';
try {
await pool.execute(query, [name, description, price, duration, id]);
const [results] = await pool.execute(query, [name, description, price, duration, userId]);
console.log('✅ Update results:', results);
return results;
} catch (error) {
console.error('Error updating tour:', error);
throw new Error('เกิดข้อผิดพลาดในการอัปเดตทัวร์');
console.error('Error updating tour:', error); // ตรวจสอบข้อผิดพลาดในฐานข้อมูล
throw error;
}
}
// ดึงทัวร์ตาม ID
static async getTourById(id) {
try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment