forked from mikeygh2/CS430-APO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnextWeekScript.inc.php
More file actions
36 lines (27 loc) · 845 Bytes
/
nextWeekScript.inc.php
File metadata and controls
36 lines (27 loc) · 845 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
27
28
29
30
31
32
33
34
35
36
<?php
function newPDO(){
$dsn = "mysql:host=localhost;dbname=CS430";
$user = "root";
$pass = "root";
return new PDO($dsn, $user, $pass);
}
/*
* Populate next week table
* default eventStatus_Id = 1, 2= active, 3=canceled
* Fri, push to occurrencqe table
* clear next week table
*/
$db = newPDO();
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$dateValue = date('N');
$dateValue -= 1;
$sql = "INSERT NextWeek (S_Id,startTime,endTime,Max)
SELECT Shift.S_Id,Event.startDate,Event.endDate,Shift.Max
FROM Shift
JOIN Event ON Event.E_Id = Shift.E_Id
WHERE (Event.startDate > (NOW()+6-$dateValue)
AND Event.startDate < (NOW()+13-$dateValue))
OR Event.Recurring = 'T'";
$stmt = $db->prepare($sql);
$stmt->execute();
print_r($stmt->errorInfo());