MDNodaHelpers/src/NodaGroup.php

60 lines
1.2 KiB
PHP
Raw Normal View History

2023-12-07 23:30:24 +01:00
<?PHP
/**
* Manages vocabulary groups.
*
* @file
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Manages vocabulary groups.
*/
final class NodaGroup {
private MDMysqli $_mysqli_noda;
/**
* Lists all active groups.
*
* @param integer $limit Limit.
* @param integer $offset Offset.
*
* @return array<array{id: int, name: string}>
*/
public function list(int $limit = 50, int $offset = 0):array {
$output = [];
$result = $this->_mysqli_noda->query_by_stmt("SELECT `group_id`, `group_name`
FROM `group`
ORDER BY `group_id` DESC
LIMIT ?
OFFSET ?", "ii", $limit, $offset);
while ($cur = $result->fetch_row()) {
$output[] = [
'id' => (int)$cur[0],
'name' => $cur[1],
];
}
$result->close();
return $output;
}
/**
* Constructor.
*
* @param MDMysqli $mysqli_noda DB connection.
*
* @return void
*/
public function __construct(MDMysqli $mysqli_noda) {
$this->_mysqli_noda = $mysqli_noda;
}
}