在寻找一种方法来临时保存搜索结果时,当用户在特定日期之间搜索免费酒店时,我遇到了临时表。
但是即使在mysql手册中也没有回答某些问题......比如......
对于执行脚本的每个用户来说,临时表是否都是唯一的......?或者当两个不同的用户同时运行脚本时它会被覆盖......?
桌子什么时候被破坏..?当用户关闭浏览器窗口或只是导航离开脚本运行的页面时......?
感谢您的澄清...
这就是我的做法......
$table = "CREATE OR REPLACE TEMPORARY TABLE $free_room(
room_id INT(5),
room_name VARCHAR(150),
max_persons INT(1),
rooms_free INT(1),
room_price INT(6),
hotel_id INT(4),
hotel_name VARCHAR(100),
hotel_stars INT(1),
hotel_type INT(1)) ENGINE=MEMORY";
$query_getFreeRooms = "INSERT INTO $free_room
SELECT $rooms.room_id,
$rooms.room_name,
$rooms.max_persons,
$rooms.total_rooms - $rooms.booked_rooms AS rooms_free,
$rooms.room_price,
$hotels.hotel_id,
$hotels.hotel_name,
$hotels.hotel_stars,
$hotels.hotel_type
FROM $hotels,$rooms
WHERE $rooms.room_id NOT IN (SELECT room_id
FROM $reservations
WHERE $dateCheck)
AND $hotels.hotel_city = '$city_search1'
AND $hotels.hotel_id = $rooms.hotel_id
AND $hotels.hotel_deleted = '0'
AND $rooms.room_deleted = '0'";