<?php
/**
 * Ministry helpers
 */

function getMemberMinistries($memberId) {
    global $pdo;
    $stmt = $pdo->prepare('
        SELECT m.id, m.name FROM ministries m
        INNER JOIN member_ministries mm ON mm.ministry_id = m.id
        WHERE mm.member_id = ?
        ORDER BY m.name
    ');
    $stmt->execute([$memberId]);
    return $stmt->fetchAll();
}

function getMemberMinistriesIds($memberId) {
    $rows = getMemberMinistries($memberId);
    return array_column($rows, 'id');
}
