NYCPHP Meetup

NYPHP.org

[nycphp-talk] Timeouts ... how to get around it?

Steve Solomon sjmci at optonline.net
Tue Oct 14 08:03:02 EDT 2008


2 more efficient ways:

1 - mysql solution - (You will have to look up the exact syntax) -
select table1.email from table1 where table1.email in (select
table2.email from table2) into table3.  This will give you all the
matches in table3.  Table1 should both probably be indexed on email, but
you can do some testing to see if that matters.

2 - 1950's solution - create 2 sorted text files containing the email
addresses.  Then march through both in PHP, looking for matches.  

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On Behalf Of mikesz at qualityadvantages.com
Sent: Tuesday, October 14, 2008 1:57 AM
To: NYPHP Talk
Subject: [nycphp-talk] Timeouts ... how to get around it?


Hello NYPHP,

  I have an array that has 13000 email addresses. For now, its in the
  script but will be in a database table eventually. It is a list of
  known bad guys.

  I have a database table with 9000 records and one of the fields is
  an email address.

  In PHP I am using a foreach to loop through the array and do a
  database lookup to try to find any matching emails.

  I am using this query inside the foreach loop:

        $res = ("SELECT * FROM `table` WHERE `email` = '$email2Chk'");
        $numRows = mysql_num_rows($res);
        if ( !empty($numRows ))


  It processes about 12000  addresses in the array and the script times
out.

  Anyone have a better idea for doing this task?

  TIA for any help.

-- 
Best regards,
 mikesz                          mailto:mikesz at qualityadvantages.com

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.169 / Virus Database: 270.8.0/1720 - Release Date:
10/11/2008 3:59 PM





More information about the talk mailing list