public static function getAddressObjectsForEntity($entityID) {
   $sql = "SELECT \"adres_id\" from \"adres\" WHERE \"jednostka_id\" = $entityID";
   $res = pg_query(DataManager::_getConnection(), $sql);

   if(!$res) {
      die("Bd odczytu adresw dla jednostki $entityID");
   }

   if(pg_num_rows($res)) {
      $objs = array();
      while($rec = pg_fetch_assoc($res)) {
         $objs[] = new Address($rec['adres_id']);
      }
      return $objs;
   } else {
      return array();
   }
}

public static function getEmailObjectsForEntity($entityID) {
   $sql = "SELECT \"email_id\" from \"email\"  WHERE \"jednostka_id\" = $entityID";
   $res = pg_query(DataManager::_getConnection(), $sql);
   if(!$res) {
      die("Bd odczytu adresw email dla jednostki $entityID");
   }

   if(pg_num_rows($res)) {
      $objs = array();
      while($rec = pg_fetch_assoc($res)) {
         $objs[] = new EmailAddress($rec['email_id']);
      }
      return $objs;
   } else {
      return array();
   }
}

public static function getPhoneNumberObjectsForEntity($entityID) {
   $sql = "SELECT \"telefon_id\" from \"telefon\"  WHERE \"jednostka_id\" = $entityID";
   $res = pg_query(DataManager::_getConnection(), $sql);

   if(!$res) {
      die("Bd odczytu numerw telefonu dla jednostki $entityID");
   }

   if(pg_num_rows($res)) {
      $objs = array();
      while($rec = pg_fetch_assoc($res)) {
         $objs[] = new PhoneNumber($rec['telefon_id']);
      }
      return $objs;
   } else {
      return array();
   }
}