Documentation Build v9.17

CantonMapper extends AbstractMapper
in package

The AbstractMapper is used to retrieve and store DomainObjects from and to the Database

A DataMapper implementation has to provide the methods for interaction
But There should be find[ByXYZ] methods to retreive the respective DomainObject and insert/update methods to store the data to the Database

Table of Contents

Constants

COLUMNS  : array<string|int, mixed> = ['taxwert' => ['id', 'taxwert', 'kanton', 'prio...
An array of all the database columns to build the query from.
JOINS  : array<string|int, joinIndex> = ['owner' => ['LEFT JOIN', \VeruA\DataMapper\Own...
An array of database joins to build the query from.
ORDERCOLUMNS  : array<string|int, mixed> = []
An array of default order columns.
TABLE  : string = 'taxwert'
The name of the database table to build the query from.
WHERE  : array<string|int, mixed> = ['`taxwert`.del=0']
An array of default where clauses concatenated by AND.

Properties

$dbc  : mysqli
$fieldMap  : array<string|int, mixed>
$map  : array<string|int, mixed>

Methods

__construct()  : mixed
delete()  : mixed
find()  : Canton
findAll()  : Iterator
Returns all DomainObjects of that type
findAllAlphabetically()  : mixed
findAllNotAcrossSwitzerlandSorted()  : mixed
findAllOrderedById()  : mixed
findAllSorted()  : mixed
findAny()  : Canton
Finds any canton by id without the default active-only filter.
findForClientByDate()  : Canton
findMany()  : DomainObjectCollection
findOne()  : DomainObject
findSelected()  : mixed
insert()  : mixed
load()  : DomainObject
loadGhost()  : void
mapValues()  : mixed
Map DomainObjectValues to database column values
sqlOrderBy()  : string
sqlWhere()  : mixed
store()  : mixed
storeMany()  : mixed
update()  : mixed
updateAll()  : mixed
abstractCreateGhost()  : DomainObject
abstractFind()  : DomainObject
Executes an sql select statement
createGhost()  : Canton
customQuery()  : Query
doLoad()  : Canton
insertQuery()  : Query
Returns a new INSERT Query Instance
query()  : Query
Returns a new SELECT Query Instance.
sqlColumns()  : string
sqlDeleteQuery()  : string
sqlInsertQuery()  : string
sqlJoins()  : string
sqlSelectQuery()  : string
sqlUpdateQuery()  : string
updateQuery()  : Query
Returns a new UPDATE Query Instance

Constants

COLUMNS

An array of all the database columns to build the query from.

public array<string|int, mixed> COLUMNS = ['taxwert' => ['id', 'taxwert', 'kanton', 'prioritaet', 'del', 'tarifsystem', 'zsr_nr', 'kuerzel_kanton', 'kvg_uvg', 'tariffs_pa', 'color', 'user', 'date']]

needs to be overwritten in the concrete implementations

self::TABLE => [col1, col2, ...]

JOINS

An array of database joins to build the query from.

public array<string|int, joinIndex> JOINS = ['owner' => ['LEFT JOIN', \VeruA\DataMapper\OwnerMapper::TABLE, 'user=`owner`.id', \VeruA\DataMapper\OwnerMapper::COLUMNS[\VeruA\DataMapper\OwnerMapper::TABLE]]]

can be overwritten in the concrete implementations

=> [<joinType>, , <joinCondition>, [col1, col2, ...]]

ORDERCOLUMNS

An array of default order columns.

public array<string|int, mixed> ORDERCOLUMNS = []

can be overwritten in the concrete implementations

TABLE

The name of the database table to build the query from.

public string TABLE = 'taxwert'

needs to be overwritten in the concrete implementations

WHERE

An array of default where clauses concatenated by AND.

public array<string|int, mixed> WHERE = ['`taxwert`.del=0']

can be overwritten in the concrete implementations

[condition1, condition2, ...]

Properties

$fieldMap

protected array<string|int, mixed> $fieldMap = []

Map DomainObjects field names to database column names

Tags
abstract

overwrite in concrete implementation with correct mapping

$map

protected static array<string|int, mixed> $map

Identity Map of DomainObjects

Methods

__construct()

public __construct(mysqli $dbc) : mixed
Parameters
$dbc : mysqli

The database Connection Object

findAll()

Returns all DomainObjects of that type

public findAll() : Iterator
Return values
Iterator

findAllAlphabetically()

public findAllAlphabetically() : mixed

findAllNotAcrossSwitzerlandSorted()

public findAllNotAcrossSwitzerlandSorted() : mixed

findAllOrderedById()

public findAllOrderedById() : mixed

findAny()

Finds any canton by id without the default active-only filter.

public findAny(int $id) : Canton

The default mapper logic keeps taxwert.del = 0, which is correct for current assignments and selection lists where only active cantons should be available. Some billing and export flows, however, read already stored canton references and must still resolve the original taxwert entry even if it was deleted or deactivated later.

Parameters
$id : int
Return values
Canton

findForClientByDate()

public findForClientByDate(int $clientId, DateTimeInterface $date) : Canton
Parameters
$clientId : int
$date : DateTimeInterface
Return values
Canton

mapValues()

Map DomainObjectValues to database column values

public mapValues(array<string|int, mixed> $values[, bool $escape = true ]) : mixed
Parameters
$values : array<string|int, mixed>

array of [fieldName => value] pairs

$escape : bool = true

If set to false the mapped value will not be mysql_real_escaped

sqlOrderBy()

public sqlOrderBy(array<string|int, mixed> $orderColumns) : string
Parameters
$orderColumns : array<string|int, mixed>
Return values
string

sqlWhere()

public sqlWhere(array<string|int, mixed> $where) : mixed
Parameters
$where : array<string|int, mixed>

storeMany()

public storeMany(mixed $dmos) : mixed
Parameters
$dmos : mixed

abstractFind()

Executes an sql select statement

protected abstractFind(string|Varchar|int $id, Query $query) : DomainObject

checks if object is already in the identity map and returns it, if not it executes the sql.

Parameters
$id : string|Varchar|int

The Primary Key

$query : Query
Tags
throws
OutOfRangeException

If the $id is not found in the database

Return values
DomainObject

customQuery()

protected customQuery() : Query

check why this would be needed, we can override query() for different queries

Return values
Query

query()

Returns a new SELECT Query Instance.

protected query() : Query

Can be overwritten to return different implementations of IQuery

Return values
Query

sqlColumns()

protected sqlColumns(array<string|int, mixed> $tableColumns) : string
Parameters
$tableColumns : array<string|int, mixed>

[$table => [ $column, ... ], ...]

Return values
string

sqlDeleteQuery()

protected sqlDeleteQuery(string $table, string $where) : string
Parameters
$table : string
$where : string

condition

Return values
string

sqlInsertQuery()

protected sqlInsertQuery(array<string|int, mixed> $values, string $table) : string
Parameters
$values : array<string|int, mixed>

[$field => $value, ...]

$table : string
Return values
string

sqlJoins()

protected sqlJoins(array<string|int, mixed> $joins) : string
Parameters
$joins : array<string|int, mixed>
Return values
string

sqlSelectQuery()

protected sqlSelectQuery(array<string|int, mixed> $columns, string $table, array<string|int, mixed> $joins, array<string|int, mixed> $where, array<string|int, mixed> $orderColumns) : string
Parameters
$columns : array<string|int, mixed>

[$table => [ $column, ... ], ...]

$table : string
$joins : array<string|int, mixed>

array of sql joins

$where : array<string|int, mixed>

array of where clauses joined with AND

$orderColumns : array<string|int, mixed>

array of order clauses joined with ,

Return values
string

sqlUpdateQuery()

protected sqlUpdateQuery(array<string|int, mixed> $values, string $table, string $where) : string
Parameters
$values : array<string|int, mixed>
$table : string
$where : string

condition

Return values
string
On this page

Search results