Multiple MYSQL queries vs. Multiple php foreach loops -
database structure:
id  galleryid                 type     file_name       description 1   `artists_2010-01-15_7c1ec`  `image`  `band602.jpg`   `red umbrella promo` 2   `artists_2010-01-15_7c1ec`  `image`  `nov7.jpg`      `cd release party` 3   `artists_2010-01-15_7c1ec`  `video`  `band.flv`      `presskit`   i'm going pull images out 1 section of application, videos on another, etc. better make multiple mysql queries each section so:
$query = mysql_query("select * galleries galleryid='$galleryid' && type='image');   ...or should building associative array , looping through array on , on whenever need use result set?
thanks thoughts.
it depends what's more important: readability or performance. i'd expect single query , prefilling php arrays faster execute, since database connections expensive, simple query each section more readable.
unless know (and not hope) you're going huge amount of traffic i'd go separate queries , worry optimising if looks it'll problem. @ point there'll other things you'll want anyway, such building data access layer , adding caching.
Comments
Post a Comment