Hier eine Funktion, die genau dies erledigt:
private function fetchUsersFromJobfunction($jobfunction) {
$sql = 'SELECT DISTINCT username FROM JRUSERJOB where jobfunction=?';
$parameterValues = [$jobfunction];
$parameterTypes = [JobRouter\Common\Database\ConnectionInterface::TYPE_TEXT]
$res = $jobDB->preparedSelect($sql, $parameterValues, $parameterTypes);
return $res;
}
Danach dann das result processing, z.B. mit einer while-Schleife:
$usersInFunctionAccounting = [];
$jobfunction = 'Accounting';
$result = fetchUsersFromJobfunction($jobfunction)
while($row = $jobDB->fetchRow($result)) {
$usersInFunctionAccounting[] = $row['username'];
}