-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathclean.php
More file actions
executable file
·26 lines (17 loc) · 802 Bytes
/
clean.php
File metadata and controls
executable file
·26 lines (17 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
/**
* This file is intended to remove duplicates from the database. A duplicate is the same event in the same room typically caused by all-day events.
*/
//SELECT DISTINCT *, COUNT(*) AS fieldCount FROM rpiwayfinding GROUP BY EventName, Room, Bldg HAVING fieldCount > 1;
$query = "DELETE FROM events USING events, events AS vtable
WHERE (events.PID > vtable.PID)
AND (events.EventName=vtable.EventName)
AND (events.Room=vtable.Room)
AND (events.Bldg=vtable.Bldg);";
$stmt = mysqli_prepare($con, $query) or die(mysqli_error($con));
mysqli_stmt_execute($stmt);
//SELECT * FROM events WHERE End <= NOW()
$query2 = "DELETE FROM events WHERE End <= '".date("Y-m-d H:i:s")."'";
$stmt2 = mysqli_prepare($con, $query2) or die(mysqli_error($con));
mysqli_stmt_execute($stmt2);
?>