I've read quite a few different people say this, so i was wondering if the following qualifies as a query inside a loop.
Originally Posted by Roger Ramjet
Say i have a class, clsPictureFinder, that has a static method called GetAllPics which returns an array containing all the picture database ID's on a certain table. I defer the object creation of an individual Picture object until i'm actually looping through them, by passing the pictureID to the constructor, which is in turn triggering another query, to populate the objects properties- a query inside a loop? eg:
Is this bad practice?
$arrPicIDs = array();
$arrPicIDs = clsPictureFinder::GetAllPics();
foreach($arrPicIDs as $key=>$value)
$objPicture = &new clsPicture($value);
echo $objPicture->getFilename() . '<br />';
echo $objPicture->getOwner() . '<br />';
echo '<hr />';