RoleMapper
extends Mapper
in package
Class RoleMapper.
Mapper class for DB calls used for the role table.
Table of Contents
- $db : ADOConnection
- DB connector.
- $logger : MonologWrapper
- Logger object.
- __construct() : mixed
- Mapper constructor.
- delete() : bool
- Delete a Role.
- findAll() : array<string|int, mixed>
- Find all roles.
- findByName() : Role
- Find a role by its name.
- findByRid() : Role
- Find a role by its ID.
- findByUid() : array<string|int, mixed>
- Find a roles a user has assigned.
- save() : bool
- Save a Role object into the DB.
- fetchRow() : mixed
- Perform an SQL statement that expects a single row.
- fetchRows() : array<string|int, mixed>
- Perform an SQL statement that expects multiple rows.
- mapArray() : Role
- Map a DB row to the internal attributes.
- saveDelete() : bool
- Perform a save or delete.
Properties
$db
DB connector.
protected
ADOConnection
$db
DB Instance.
$logger
Logger object.
protected
MonologWrapper
$logger
Methods
__construct()
Mapper constructor.
public
__construct(ADOConnection $dbLayer, MonologWrapper $logger) : mixed
Parameters
- $dbLayer : ADOConnection
-
DB connection object.
- $logger : MonologWrapper
-
Logger object.
Return values
mixed —delete()
Delete a Role.
public
delete(Role $role) : bool
Parameters
- $role : Role
-
Role object.
Tags
Return values
bool —Success.
findAll()
Find all roles.
public
findAll([array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed> = []
-
Filter parameters.
Tags
Return values
array<string|int, mixed> —Array of role objects.
findByName()
Find a role by its name.
public
findByName(string $name) : Role
Parameters
- $name : string
-
Role name.
Tags
Return values
Role —Role object.
findByRid()
Find a role by its ID.
public
findByRid(int $rid) : Role
Parameters
- $rid : int
-
Role ID.
Tags
Return values
Role —Role object.
findByUid()
Find a roles a user has assigned.
public
findByUid(int $uid) : array<string|int, mixed>
Parameters
- $uid : int
-
User ID.
Tags
Return values
array<string|int, mixed> —Array of role objects.
save()
Save a Role object into the DB.
public
save(Role $role) : bool
Parameters
- $role : Role
-
Role object.
Tags
Return values
bool —Success.
fetchRow()
Perform an SQL statement that expects a single row.
protected
fetchRow(string $sql, array<string|int, mixed> $bindParams) : mixed
Parameters
- $sql : string
-
Query string.
- $bindParams : array<string|int, mixed>
-
Array of bind params.
Tags
Return values
mixed —Mapped row.
fetchRows()
Perform an SQL statement that expects multiple rows.
protected
fetchRows(string $sql[, array<string|int, mixed> $bindParams = [] ][, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $sql : string
-
Query string.
- $bindParams : array<string|int, mixed> = []
-
Array of bind params.
- $params : array<string|int, mixed> = []
-
Parameters (optional). Example: [ 'filter' => [ 'keyword' => string, 'column' => string, ] 'order_by' => string, 'direction' => string "ASC"|"DESC", 'offset' => int, 'limit' => int, ] NOTE: * This will throw an exception if the sql already contains a WHERE clause and should be calculated separately in these cases. * ['filter']['keyword'] '%' characters in keyword not added to keyword automatically.
Tags
Return values
array<string|int, mixed> —Array of mapped rows.
mapArray()
Map a DB row to the internal attributes.
protected
mapArray(array<string|int, mixed> $row) : Role
Parameters
- $row : array<string|int, mixed>
-
DB row.
Return values
Role —Role object.
saveDelete()
Perform a save or delete.
protected
saveDelete(string $sql, array<string|int, mixed> $bindParams) : bool
Parameters
- $sql : string
-
Query string.
- $bindParams : array<string|int, mixed>
-
Array of bind params.
Tags
Return values
bool —Success status.