[thelist] Time stamping and emails

Adrian Fischer adrian at logo-logic.com
Sun Jul 29 07:00:13 CDT 2001


Hi Gang,

Not sure that Ive got the right subject heading for this.
Ive got a program that sends emails as a result of some user interaction.  I
have my program attach a text ad to the bottom of every email.  I need to be
able to select the ads so that they all get a go at being sent eventualy.  I
was initially keeping tabs on how many times an ad was sent and then
selecting the ad with the lowest number of sends to be sent next.  Problem
with that is, when a new ad is added it has no hits so gets sent until it
catches up with the older ones.  Not very good.  I had a brain storm and
thought that if I put a time stamp in there and used that as the criteria
then all would be sweet.  Send the next ad with the lowest time stamp.
Sounded good.  Didnt realise that the system sends emails very quickly and
that as result the same adds gets sent lots of times within a one second
time frame.  (this is using perl time()).  I can set the server to sleep
between sends but what if I had 100 plus emails going out and Iused sleep 1;
the system would bog down.

I need something that breaks down time to milliseconds perhaps.  Is ther a
function in perl for that or in mysql.  Geeze how hard could it be to work
this out. Ive been at it for about 6 hours now and have hit a brick wall.

Any and all solutions would be appreciated.

If it helps here is the select statement:
<snip>
my $dbh=$db->prepare("SELECT adId,BusName,BusAddress,Suburb,YourAd FROM
tblAds WHERE State ='$docstate' AND Pending = 0 ORDER BY adTime ASC LIMIT 1
");
$dbh->execute();
($adid,$busname,$busaddress,$suburb,$yourad) = $dbh->fetchrow_array();

my $dbh=$db->do("UPDATE tblAds SET AdHits=Adhits+1,adTime=$current_time
WHERE AdId ='$adid' ");
</snip>

I dont want random.  Just dont know what other criteria  could select on??

Thanks

Adrian Fischer
Australia





More information about the thelist mailing list