fetchGroupsByMenu (function)

Last updated: Mon, Apr 17, 2023 9:16 am
Return to Knowledgebase

Purpose

Location

users/helpers/us_helpers.php

Parameters

# Parameter Data Type Required Description
1 $menu_id integer Yes An integer representing the ID of the menu for which the groups are to be fetched

Returns

Data Type Description of Returned Data
array of objects Returns an array of objects representing the results of the query.

Further Documentation:

The function fetches the id and group_id columns from the groups_menus table for the specified $menu_id using a prepared statement. It returns an array of objects representing the results of the query.

Each object in the array has two properties:

id - An integer representing the ID of the record in the groups_menus table.
group_id - An integer representing the ID of the group associated with the menu.
Here's an example of how to use the fetchGroupsByMenu() function:
 
$menu_id = 2;
$groups = fetchGroupsByMenu($menu_id);

foreach ($groups as $group) {
echo "Group ID: " . $group->group_id . "
";
}

This example fetches the groups associated with the menu with an ID of 2 and prints the group IDs.