Efficient Code?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
acidHL
Forum Commoner
Posts: 41
Joined: Wed Dec 07, 2005 7:38 am

Efficient Code?

Post by acidHL »

Hi Guys,

I'm developing a system for a client that is used to arrange the swap and rental of holiday homes.
I need to implement a cron job that runs through new properties (based in 3 tables, one for homes, boats and caravans) and e-mail's users who have expressed an interest in the property type and location.

I have a little psuedo-code, i'm just wondering if this is an efficient way to do it?

Code: Select all

For each property type
{
    For each new property in property_table (selected based on date)
    {
         Find members in members database with matching type and country preferences
         If the member isn't already in the temporary table
         {
              add match details temporary table and add link to the property
         } else {
              add a link to the existing record
         }
    }
}

Run through each item in the temporary table and e-mail the information to the member
It seems to me i'll be running a lot of queries if this database gets big. Does anybody have a better way of doing this?

I intend to e-mail using PHPmailer and I am working with PHP4.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

It all depends on your tables and queries.. And the functions your SQL DBMS supports.. As long as we don't know them it's hard to say something...
acidHL
Forum Commoner
Posts: 41
Joined: Wed Dec 07, 2005 7:38 am

Post by acidHL »

When I get chance i'll write some code and post a copy of the DB schema. Thanks anyway.
Post Reply