Add new class NodaGroup
This commit is contained in:
parent
50cb33720b
commit
27e259072c
59
src/NodaGroup.php
Normal file
59
src/NodaGroup.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?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;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user