-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a database truncation script (#73)
* It truncates the existing entries in the nothing private database. * It increments the number saved in visitors.txt by the number of deleted rows
- Loading branch information
1 parent
fafe03e
commit 42ade06
Showing
3 changed files
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ node_modules | |
cypress/videos/ | ||
cypress/screenshots/ | ||
docker/data | ||
db_server/visitors.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
require_once __DIR__ . '/connection.php'; | ||
|
||
$stmt = $mysqli->prepare('SELECT count(*) cnt FROM browsertab'); | ||
$stmt->execute(); | ||
$stmt->bind_result($count_from_db); | ||
$stmt->fetch(); | ||
$stmt->free_result(); | ||
|
||
$visitors_file_name = __DIR__ . '/visitors.txt'; | ||
$count_from_file = (int)@file_get_contents($visitors_file_name); | ||
file_put_contents($visitors_file_name, $count_from_db + $count_from_file); | ||
|
||
$stmt = $mysqli->prepare('TRUNCATE TABLE browsertab'); | ||
$stmt->execute(); |