-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUpdateSubscribers.php
More file actions
29 lines (26 loc) · 1020 Bytes
/
Copy pathUpdateSubscribers.php
File metadata and controls
29 lines (26 loc) · 1020 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
<?php
// Connection Variables
$host = "host=HOST_HERE";
$port = "port=PORT_HERE";
$dbname = "dbname=DBNAME_HERE";
$credentials = "user=USER_HERE password=PASSWORD_HERE";
$current_time = strtotime("now");
// Open database
$dbConnection = pg_connect( "$host $port $dbname $credentials" );
if(!$dbConnection){
echo "Error : Unable to open database.\n";
} else {
echo "Opened database successfully.\n";
}
// Get all expired subscribers, and remove their subscription
$queryExpired = 'SELECT * FROM "BarscriptionRecord" WHERE now() >= expires';
$result = pg_query($dbConnection, $queryExpired);
while($row = pg_fetch_assoc($result)) {
$memberId = $row['memberId'];
$queryUpdateFlags = 'UPDATE "MemberRecord" set flags = 256 WHERE "memberId"='.$memberId.'';
pg_query($dbConnection, $queryUpdateFlags);
$queryRemoveSubscriber = 'DELETE FROM "BarscriptionRecord" WHERE "memberId"='.$memberId.'';
pg_query($dbConnection, $queryRemoveSubscriber);
}
pg_close($dbConnection); //close the database
?>