Hello,
I have a downloading website, where i measure the bandwidth used by every member.
For example the member is downloading a 1GB file, i want to measure how amny MB the user has downloaded in.
I'm currently using this code, it works but it creates huge load on the my server
Code:
while (!feof($fp) && (connection_status()==0)) {
$recv = @stream_get_line($fp, 1048577);
@print $recv;
@flush();
@ob_flush();
$query = mysql_query("UPDATE userband SET today = today + 1 WHERE username='$username'");
$query = mysql_query("UPDATE userband SET month = month + 1 WHERE username='$username'");
$query = mysql_query("UPDATE userband SET total = total + 1 WHERE username='$username'");
}
is there a more efficient way to do this? i keep track of bandwidth used in month, yeat and total. as you can see for every 1MB of chunk data 3 SQL statements are executed but the download happens fast so many many sql statements are executed in one second
Advice is appreciated, thank you