ApiOpenStudio PHPDoc

Mapper
in package

Abstract class Mapper.

All derived Mapper classes but extend this class.

Table of Contents

$db  : ADOConnection
DB connector.
$logger  : MonologWrapper
Logger object.
__construct()  : mixed
Mapper constructor.
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()  : mixed
Map a DB row into an object.
saveDelete()  : bool
Perform a save or delete.

Properties

$db

DB connector.

protected ADOConnection $db

DB Instance.

Methods

__construct()

Mapper constructor.

public __construct(ADOConnection $dbLayer, MonologWrapper $logger) : mixed
Parameters
$dbLayer : ADOConnection

DB connection object.

$logger : MonologWrapper

Logger object.

Return values
mixed

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
throws
ApiException

Return an ApiException on DB error.

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
throws
ApiException

Return an ApiException on DB error.

Return values
array<string|int, mixed>

Array of mapped rows.

mapArray()

Map a DB row into an object.

protected abstract mapArray(array<string|int, mixed> $row) : mixed
Parameters
$row : array<string|int, mixed>

DB row.

Return values
mixed

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
throws
ApiException

Return an ApiException on DB error.

Return values
bool

Success status.

Search results