/** * @param $id number * @return class ReturnDataVO */ public function selectByUserId($typeOfReturn = NULL, $id) { $typeOfReturn = DbInterface::RETURN_STD_OBJECT; $query = "SELECT \r\n\t\t\t\t\t\t\taddress.*,\r\n\t\t\t\t\t\t\tstate.name as state_name,\r\n\t\t\t\t\t\t\tcountry.name as country_name\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\tuser_address\r\n\t\t\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\t\t\taddress \r\n\t\t\t\t\t\t\t\t\t\tON address.id = user_address.address_id\r\n\t\t\t\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\t\t\t\tstate\r\n\t\t\t\t\t\t\t\t\t\tON address.state_id = state.id \r\n\t\t\t\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\t\t\t\tcountry\r\n\t\t\t\t\t\t\t\t\t\tON country.id = state.country_id \r\n\t\t\t\t\t\tWHERE user_address.user_id = " . $id; $AddressDAO = new AddressDAO(); //executa a query $ReturnDataVO = $AddressDAO->query($query); //echo $query; if ($ReturnDataVO->success) { switch ($typeOfReturn) { case DbInterface::RETURN_ARRAY: $ReturnDataVO->fetchAll(ReturnDataVO::TYPE_FETCH_ARRAY); break; case DbInterface::RETURN_VO: $ReturnDataVO->fetchAllVO($ReturnDataVO); break; case DbInterface::RETURN_STD_OBJECT: default: //retornar tudo em objeto $ReturnDataVO->fetchAll(ReturnDataVO::TYPE_FETCH_OBJECT); break; } return $ReturnDataVO; } else { return $ReturnDataVO; } }