kidd has asked for the wisdom of the Perl Monks concerning the following question:
I create a CGI to administrate news items, I've created the database on MySQL. Each of the news items has a timestamp field to know the date and time each of the news where submited.
When a user sees a news item I run a function that adds the number of views that item has:
The code runs correctly and adds the views without a problem. The thing is that when I update the views field, the timestamp field is also updated.sub add_views{ my $id = shift; my $current_views = shift; my $new_views = $current_views + 1; my($dbh,$sth); $dbh = BaboonDB->connect(); $sth = $dbh->prepare('UPDATE news SET views=? WHERE id=?') or die(" +Couldn't prepare statement: " . $dbh->errstr); $sth->execute($new_views,$id) or die("Couldn't execute statement: " + . $sth->errstr); $sth->finish; $dbh->disconnect; return($new_views); }
What I would like to know if there is a way to avoid this?
THANKS
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Bug on MySQL? timestamp problem
by antirice (Priest) on Aug 11, 2003 at 23:11 UTC | |
Re: Bug on MySQL? timestamp problem
by liz (Monsignor) on Aug 11, 2003 at 23:12 UTC | |
Re: Bug on MySQL? timestamp problem
by Anonymous Monk on Aug 11, 2003 at 23:28 UTC | |
by skyknight (Hermit) on Aug 12, 2003 at 01:04 UTC | |
Re: Bug on MySQL? timestamp problem
by chromatic (Archbishop) on Aug 12, 2003 at 01:15 UTC | |
Re: Bug on MySQL? timestamp problem
by CountZero (Bishop) on Aug 12, 2003 at 05:48 UTC |