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
In reply to Bug on MySQL? timestamp problem by kidd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |