BoysLikeGirlsLikeMeD
New Member
This might be something very trivial, but I am a novice with some Object-Oriented patterns.Put simply, is it a bad practice to use methods from one DAO in another DAO? I am trying to create an entity within a DAO and find it very hard to create that entity using just that DAO. So, is it ok to use other DAO methods within the other DAO?Example:\[code\]public function readAllUsers() { $sql = "SELECT * FROM user"; return $this->execute($sql);}public function execute($sql) {$result = mysql_query($sql, $this->getDBConnection()) or die(mysql_error()); $user = array(); if(mysql_num_rows($result) > 0) { for($i = 0; $i < mysql_num_rows($result); $i++) { $row = mysql_fetch_assoc($result); $user[$i]->setUsername(row["userName"]); ...set user info... $user[$i]->setAddresses($addressDAO->readAddressByUserId($userId)); } } return $user;}\[/code\]NOTE: There are a good bit of attributes like this in the user entity that have a one-to-many relationship with the entity itself (addresses, emails, phone numbers, etc.). The query that would be needed (with all the linking tables that are used) would be tremendously complex.Thanks,Steve