in reply to Re^6: Making an automatic counter adder for all webpages
in thread Making an automatic counter adder for all webpages
is equivalent to$db->do('UPDATE counters SET pagecounter = pagecounter + 1 WHERE pagen +ame = ?', undef, $pagename);
my $sth = $db->prepare( 'UPDATE counters SET pagecounter = pagecounter + 1 WHERE pagename = + ?'); $sth->execute($pagename);
As you can see, there's a lot to read in the DBI documentation ;)my ($counter) = $db->selectrow_array('SELECT pagecounter FROM counters + WHERE pagename = ?', undef, $pagename);
sub increase_pagecount_for { my ($db, $pagename) = @_; eval { # Just ignore errors if the record already exists $db->do('INSERT INTO counters (pagename, pagecounter) VALUES (?, + 0)', undef, $pagename); }; $db->do( 'UPDATE counters SET pagecounter = pagecounter + 1 ' . ' WHERE pagename = ?', undef, $pagename ); my ($counter) = $db->selectrow_array( 'SELECT pagecounter FROM counters WHERE pagename = ?', undef, $pagename ); return $counter; } ## end sub increase_pagecount_for
Hey! Up to Dec 16, 2007 I was named frodo72, take note of the change! Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Making an automatic counter adder for all webpages
by Nik (Initiate) on Dec 24, 2007 at 10:34 UTC | |
by polettix (Vicar) on Dec 24, 2007 at 12:45 UTC | |
|