Or do you rather execute one large SQL statement in the UserManager model. For instance something like:function userManager::getAllByCity( $city ) { $users = array(); $sql = ' SELECT columns FROM user LEFT JOIN image LEFT JOIN video # etc.... '; $result = $db->execute( $sql ); foreach( $result as $row ) { if( !isset( $users[ $row[ 'id' ] ] ) ) { $users[ $row[ 'id' ] ] = new User_Model(); } if( !$users[ $row[ 'id' ] ]->hasImage( $row[ 'imageId' ] ) ) { $users[ $row[ 'id' ] ]->addImage( $row[ 'imageId' ], $row[ 'imageLocation' ] ); } if( !$users[ $row[ 'id' ] ]->hasVideo( $row[ 'videoId' ] ) ) { $users[ $row[ 'id' ] ]->addVideo( $row[ 'videoId' ], $row[ 'videoLocation' ] ); } // etc.... } return $users; } $users = $userManager->getAllByCity( 'Amsterdam' );
I would use the join method. Calling out to the database is an
expensive operation, so I try to minimize the number of calls. Also,
try not to think in terms of loops when you consider data, it is more
based in set theory.
- [fw-general] [OT] General design question fire-eyed-boy
- Re: [fw-general] [OT] General design question fire-eyed-boy
- Re: [fw-general] [OT] General design question Deanna Bonds
- Re: [fw-general] [OT] General design question Jurian Sluiman
- [fw-general] Back again to the Zend Framew... Carlos Medina
- Re: [fw-general] Back again to the Ze... Isaak Malik
- Re: [fw-general] [OT] General design quest... fire-eyed-boy
- Re: [fw-general] [OT] General design ... Jurian Sluiman
- Re: [fw-general] [OT] General design question fire-eyed-boy
- Re: [fw-general] [OT] General design quest... Deanna Bonds
