With version 1.02 out, I sat down to figure out the rules of the road, so to speak. Keyword logging should be just a simple subroutine call:
if exists 'keyword' increment count,
otherwise, add new record
return
Well.... it was all that and more <G>
The table I used is very simple:
# Host: localhost Database : links
# --------------------------------------------------------
#
# Table structure for table 'Search_Log'
#
CREATE TABLE Search_Log (
ID int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
Term char(25) NOT NULL,
Count int(11) DEFAULT '0' NOT NULL,
Last_Look bigint(21) DEFAULT '0' NOT NULL,
PRIMARY KEY (ID),
UNIQUE Term (Term)
);
The above code will actually create the database table if used in the SQL command box. You can change the table name, but "Search_Log" was pretty intuitive.
The Search_Log.def file is:
# Created on: Mon Aug 23 21:52:54 1999
#
package Links:
foreach $hit_arr(@$hits){
my $hit_hash =$db_table->array_to_hash($hit_arr); ## convert array to hash
$hit_hash->{'Count'} = $hit_hash->{'Count'} + 1; ## increment _Count_ field
$db_table->modify_record($hit_hash); ## send hash to _modify_
}
} else { ## more than one record found
## database contained multiple matches... error
print "Hit my only error condition found";
&site_html_search_failure ({ error => "More than one exact database match.", %in }) and return;
} ## if_elseif
} ## log_search
No utilties yet, but this does the job...
I'm sure it could be done in fewer lines, and with neater calls, but this explains the logic, at least. The kludge is that I still had not figured out all the calls, so I just used Alex's boilerplate.
---
BTW: Alex... smiley's are cute, but they affect the programming -- BSQL becomes {confused smiley}BSQL
[This message has been edited by pugdog (edited August 23, 1999).]
if exists 'keyword' increment count,
otherwise, add new record
return
Well.... it was all that and more <G>
The table I used is very simple:
Code:
# # Host: localhost Database : links
# --------------------------------------------------------
#
# Table structure for table 'Search_Log'
#
CREATE TABLE Search_Log (
ID int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
Term char(25) NOT NULL,
Count int(11) DEFAULT '0' NOT NULL,
Last_Look bigint(21) DEFAULT '0' NOT NULL,
PRIMARY KEY (ID),
UNIQUE Term (Term)
);
The above code will actually create the database table if used in the SQL command box. You can change the table name, but "Search_Log" was pretty intuitive.
The Search_Log.def file is:
Code:
# Auto Generated Config File. # Created on: Mon Aug 23 21:52:54 1999
#
package Links:
foreach $hit_arr(@$hits){
my $hit_hash =$db_table->array_to_hash($hit_arr); ## convert array to hash
$hit_hash->{'Count'} = $hit_hash->{'Count'} + 1; ## increment _Count_ field
$db_table->modify_record($hit_hash); ## send hash to _modify_
}
} else { ## more than one record found
## database contained multiple matches... error
print "Hit my only error condition found";
&site_html_search_failure ({ error => "More than one exact database match.", %in }) and return;
} ## if_elseif
} ## log_search
No utilties yet, but this does the job...
I'm sure it could be done in fewer lines, and with neater calls, but this explains the logic, at least. The kludge is that I still had not figured out all the calls, so I just used Alex's boilerplate.
---
BTW: Alex... smiley's are cute, but they affect the programming -- BSQL becomes {confused smiley}BSQL
[This message has been edited by pugdog (edited August 23, 1999).]