-
Notifications
You must be signed in to change notification settings - Fork 20
/
cwslack-lunch-cron.php
19 lines (15 loc) · 808 Bytes
/
cwslack-lunch-cron.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
// Schedule your cron tab using code below. Windows Task Scheduler and other scheduled systems should also work, if all else fails you can do a MySQL event for it.
// 0 0 * * * /usr/bin/php /var/www/cwslack-lunch-cron.php >/dev/null 2>&1
// May have to adjust locations of php and this file if they are different on your system
$mysql = mysqli_connect($dbhost, $dbusername, $dbpassword, $dbdatabase); //Connect MySQL
if (!$mysql) //Check for errors
{
die("Connection Error: " . mysqli_connect_error()); //Return properly encoded arrays in JSON for Slack parsing.
}
$sql = "UPDATE lunch SET lunchtoday = 0, lunchon = 0, lunchend = NULL, lunchstart = NULL";
if (mysqli_query($mysql, $sql)) {
//Table cleared successfully
} else {
die("lunch Table Clear Error: " . mysqli_error($mysql));
}