Jump to content

resetting stats


ldoozer

Recommended Posts

I have a database with lots of tables and many tables have a field called requests which hold how many times a page for instance has been requested.

 

Here the thing - now that the website has been tested, i want to reset all the stats to 0.

Can i do this in one sql statement?

Link to comment
Share on other sites

why would you have so many tables with respect to a single data type (number of page request?)

 

 

Should be a single table and then you could easily just write.

 

 

<?php
$q = "Update `Reqest_Count_table` Set Hit_Count = '0'";
$r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
?>

 

That would update all counts to 0 in that table

Link to comment
Share on other sites

just realised that I dont have the class that connects to the db. need to do this:

$update_field = "Hit_Cont";
foreach($tables as $value){
$q = "Update `".$value."` Set ".$update_field."='0'";
$r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
}
?>

but in sql?

Link to comment
Share on other sites

If the columns have a default value of 0, couldn't you just use

$sql = mysql_query("TRUNCATE TABLE table_name");

 

 

 

No!

 

Truncate will empty all records out of a table

 

Right. he said he wanted to reset all to zero. I take that as meaning 'starting from scratch'. If each column has a default value of 0, then he will achieve his goal. Otherwise, why reset to zero?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.