sulfericacid has asked for the wisdom of the Perl Monks concerning the following question:
Can someone assist me with the logic of how to go about setting this up? I'm converting my link tracker over to a MySQL backend to make the data more sortable.
What it's doing here is checking a url_param for the referring URL and checking whether or not it was in the id row already. If it wasn't, it'll setup the current data (the ip address, the time it was clicked and will start with 1 view).
If the url was already setup, it will autoincrement "views", store the current IP address in last_ip (overwriting original value) and store it with ALL ips in all_ip.
I'm to the point where I bind the variables to the columns but from here I don't know what to do.
Any assistance would be much appreciated.
###### # Connecting to our database ###### my $dbh = DBI->connect("DBI:mysql:$dbase", $mysql_user, $mysql_pass) o +r print DBI=>"errstr"; my $url = url_param("url"); ###### # Was the referring URL in the database? or not ###### my $data = qq(SELECT id, views, last_ip, last_time, all_ip FROM track +where id = "$url"); my $sth = $dbh->prepare($data); $sth->execute() or die $dbh->errstr; if ($sth->rows < 1) { my ($id, $views, $last_ip, $last_time, $all_ip); $sth->bind_columns(\$id, \$views, \$last_ip, \$last_time, \$all_ip) +; # nothing was here so we'll setup the values starting with 1 view } else { my ($id, $views, $last_ip, $last_time, $all_ip); $sth->bind_columns(\$id, \$views, \$last_ip, \$last_time, \$all_ip) +; # this URL was tracked previously, we have to autoincrement $views +and store all our info }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MySQL logic
by jZed (Prior) on May 27, 2005 at 20:08 UTC | |
|
Re: MySQL logic
by samtregar (Abbot) on May 27, 2005 at 20:30 UTC | |
|
Re: MySQL logic
by johnnywang (Priest) on May 27, 2005 at 21:19 UTC | |
|
Re: MySQL logic
by monarch (Priest) on May 28, 2005 at 06:08 UTC | |
|
Re: MySQL logic
by trammell (Priest) on May 27, 2005 at 22:44 UTC |