Jump to content

Archived

This topic is now archived and is closed to further replies.

SlimSlyk

Clear a Field Nightly

Recommended Posts

Hello,

I have a database table with a structure like this:
id
title
url
total_clicks
today_clicks

Basically, I want to select all of the rows where today_clicks does not equal 0 (To prevent unnecessary load at 00:00 when a server seems most likely to crash anyways), and have it clear today_clicks for all of those rows. I was thinking that a foreach would be needed, but I don't have my PHP book handy and don't really know how to structure one.

Could someone help me out here please?

Thanks!

Share this post


Link to post
Share on other sites
I'm not sure if I understand what you're asking, but let me just attempt an answer. If you want this to be done nightly automatically then you'll need to schedule a cron job to run a PHP script. It cannot be done with PHP alone. If you're just interested in going everynight and running the script through your browser then that would work fine. I run a query like:
UPDATE $tablename SET $changingrow = '0' WHERE $someotherrow = '$somecondition'
I hope you can see the intent behind the query, just swap in your values for mine.

Share this post


Link to post
Share on other sites
I know that I will need to run a cron job to do this.

Mostly I guess I am curious to know how I can select rows from the table where today_clicks does _not_ equal 0. From there I should be able to do a where() to update each row.

Share this post


Link to post
Share on other sites

×

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.