Redroest Posted October 1, 2010 Share Posted October 1, 2010 Hey people. Im stuck again.I am building a framework based on the Model View Controller principe. My model has an query function like below: <?php //Load all default modules public function getBlockModules() { $sql = 'SELECT * FROM core_modules WHERE blockMode=1'; if(!$ModuleQuery = $this->db->query($sql)) { trigger_error('Error in the modulequery: '.$this->db->error); } else { $rows = array(); while($row = $ModuleQuery->fetch_object()) { $rows[] = $row; } return $rows; } }?> And my controller function to retreive data looks like this: <?php //Load all blocks $modules = $this->Model->getBlockModules(); foreach($modules AS $property) { //Load module into the view object $this->View->setContainer('modules/'.$property->controllerFile, 'modules/'.$property->headerFile, 'themes/Redroest/'.$property->layoutFile, $property->title, $property->positionTag); } }?> As you can see, I need 2 loops in order to keep the data separated from the logic part. Is there a way to prevent multiple loops from happening and still keeping the logics separated? Link to comment Share on other sites More sharing options...
wirehopper Posted October 2, 2010 Share Posted October 2, 2010 You might want to check out some of the existing frameworks to get ideas. Link to comment Share on other sites More sharing options...
Redroest Posted October 2, 2010 Author Share Posted October 2, 2010 Well some frameworks apply the method I just told. I guess it depends on what is important. Smart technologie or performance Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.