si-blog

Best use of MySQL and PHP

Posted Apr 21, 2004 in PHP.

While adding things to my referrals page, I started to consider how best to retrieve and deliver the results I needed. The way I see it, there are two options:

  1. Create a large query that gets all the data neeeded, and then use PHP to extract the data as needed
  2. Have multiple queries (one for each resultset needed) and reduce the code footprint

I have always adopted the latter approach, because it enables me to keep each little piece of functionality separate, so that I can move chunks around as needed. In either case, I am still only making a single database connection, performing one or more queries, and then closing the connection.

Which option do you think is the best approach? Is my use of multiple queries wasteful, or would the extra PHP necessary be just as wasteful?

Comments

There are no comments associated with this entry.