<?php
// Connect to MySQL server
$db_host = "localhost";
$db_user = "username";
$db_pass = "password";
$db_name = "database_name";
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Delete all customer data from database
$delete_customer_data = "DELETE FROM customers WHERE is_demo = 0";
if (mysqli_query($conn, $delete_customer_data)) {
echo "Customer data deleted successfully" . PHP_EOL;
} else {
echo "Error deleting customer data: " . mysqli_error($conn) . PHP_EOL;
}
// Close connection to MySQL server
mysqli_close($conn);
?>
To set up the cron job, you would need to add this script to your server and configure the cron daemon to run it at a specific time every day. For example, to run the script at midnight every day, you could add the following line to the crontab file:
0 0 * * * /path/to/reset_database.php