Overview

Namespaces

  • CRUDlex

Classes

  • CRUDControllerProvider
  • CRUDData
  • CRUDEntity
  • CRUDEntityDefinition
  • CRUDEntityValidator
  • CRUDMySQLData
  • CRUDMySQLDataFactory
  • CRUDServiceProvider
  • CRUDSimpleFilesystemFileProcessor
  • CRUDStreamedFileResponse

Interfaces

  • CRUDDataFactoryInterface
  • CRUDFileProcessorInterface
  • Overview
  • Namespace
  • Class

Class CRUDMySQLData

MySQL CRUDData implementation using a given Doctrine DBAL instance.

CRUDlex\CRUDData
Extended by CRUDlex\CRUDMySQLData
Namespace: CRUDlex
Located at CRUDMySQLData.php
Methods summary
protected
# setValuesAndParameters( CRUDlex\CRUDEntity $entity, Doctrine\DBAL\Query\QueryBuilder $queryBuilder, boolean $setValue )

Sets the values and parameters of the upcoming given query according to the entity.

Sets the values and parameters of the upcoming given query according to the entity.

Parameters

$entity
the entity with its fields and values
$queryBuilder
the upcoming query
$setValue
whether to use QueryBuilder::setValue (true) or QueryBuilder::set (false)
protected
# deleteChildren( integer $id, boolean $deleteCascade )

Performs the cascading children deletion.

Performs the cascading children deletion.

Parameters

$id
the current entities id
$deleteCascade
whether to delete children and subchildren
protected boolean
# hasChildren( integer $id )

Checks whether the by id given entity still has children referencing it.

Checks whether the by id given entity still has children referencing it.

Parameters

$id
the current entities id

Returns

boolean
true if the entity still has children
protected integer
# doDelete( CRUDlex\CRUDEntity $entity, boolean $deleteCascade )

Performs the actual deletion.

Performs the actual deletion.

Parameters

$entity
the id of the entry to delete
$deleteCascade
whether to delete children and subchildren

Returns

integer
true on successful deletion
protected
# addFilter( Doctrine\DBAL\Query\QueryBuilder $queryBuilder, array $filter, array $filterOperators )

Adds sorting parameters to the query.

Adds sorting parameters to the query.

Parameters

$queryBuilder
the query
$filter
filter all resulting entities must fulfill, the keys as field names
$filterOperators
operators of the filter like "=" defining the full condition of the field
protected
# addPagination( Doctrine\DBAL\Query\QueryBuilder $queryBuilder, integer|null $skip, integer|null $amount )

Adds pagination parameters to the query.

Adds pagination parameters to the query.

Parameters

$queryBuilder
the query
$skip
the rows to skip
$amount
the maximum amount of rows
protected
# addSort( Doctrine\DBAL\Query\QueryBuilder $queryBuilder, string|null $sortField, boolean|null $sortAscending )

Adds sorting parameters to the query.

Adds sorting parameters to the query.

Parameters

$queryBuilder
the query
$sortField
the sort field
$sortAscending
true if sort ascending, false if descending
protected
# fetchReferencesForField( array & $entities, string $field )

Adds the id and name of referenced entities to the given entities. The reference field is before the raw id of the referenced entity and after the fetch, it's an array with the keys id and name.

Adds the id and name of referenced entities to the given entities. The reference field is before the raw id of the referenced entity and after the fetch, it's an array with the keys id and name.

Parameters

$entities

$entities the entities to fetch the references for

$field
the reference field
protected string|null
# generateUUID( )

Genereates a new UUID.

Genereates a new UUID.

Returns

string|null
the new UUID or null if this instance isn't configured to do so
public
# __construct( CRUDlex\CRUDEntityDefinition $definition, CRUDlex\CRUDFileProcessorInterface $fileProcessor, $db, boolean $useUUIDs )

Constructor.

Constructor.

Parameters

$definition
the entity definition
$fileProcessor
the file processor to use
$db
Doctrine DBAL instance to use
$useUUIDs
flag whether to use UUIDs as primary key
public CRUDlex\CRUDEntity
# get( string $id )

Gets the entity with the given id.

Gets the entity with the given id.

Parameters

$id
the id

Returns

CRUDlex\CRUDEntity
the entity belonging to the id or null if not existant
public CRUDlex\CRUDEntity[]
# listEntries( array $filter = array(), array $filterOperators = array(), integer $skip = null, integer $amount = null, string $sortField = null, boolean $sortAscending = null )

Gets a list of entities fullfilling the given filter or all if no selection was given.

Gets a list of entities fullfilling the given filter or all if no selection was given.

Parameters

$filter
the filter all resulting entities must fulfill, the keys as field names
$filterOperators
the operators of the filter like "=" defining the full condition of the field
$skip
if given and not null, it specifies the amount of rows to skip
$amount
if given and not null, it specifies the maximum amount of rows to retrieve
$sortField
if given and not null, it specifies the field to sort the entries
$sortAscending

if given and not null, it specifies that the sort order is ascending, descending else

Returns

CRUDlex\CRUDEntity[]
the entities fulfilling the filter or all if no filter was given
public boolean
# create( CRUDlex\CRUDEntity $entity )

Persists the given entity as new entry in the datasource.

Persists the given entity as new entry in the datasource.

Parameters

$entity
the entity to persist

Returns

boolean
true on successful creation
public
# update( CRUDlex\CRUDEntity $entity )

Updates an existing entry in the datasource having the same id.

Updates an existing entry in the datasource having the same id.

Parameters

$entity
the entity with the new data
public array
# getReferences( string $table, string $nameField )

Gets ids and names of a table. Used for building up the dropdown box of reference type fields.

Gets ids and names of a table. Used for building up the dropdown box of reference type fields.

Parameters

$table
the table
$nameField
the field defining the name of the rows

Returns

array
an array with the ids as key and the names as values
public integer
# countBy( string $table, array $params, array $paramsOperators, boolean $excludeDeleted )

Retrieves the amount of entities in the datasource fulfilling the given parameters.

Retrieves the amount of entities in the datasource fulfilling the given parameters.

Parameters

$table
the table to count in
$params
an array with the field names as keys and field values as values
$paramsOperators
the operators of the parameters like "=" defining the full condition of the field
$excludeDeleted
false, if soft deleted entries in the datasource should be counted, too

Returns

integer
the count fulfilling the given parameters
public
# fetchReferences( array & $entities = null )

Adds the id and name of referenced entities to the given entities. Each reference field is before the raw id of the referenced entity and after the fetch, it's an array with the keys id and name.

Adds the id and name of referenced entities to the given entities. Each reference field is before the raw id of the referenced entity and after the fetch, it's an array with the keys id and name.

Parameters

$entities

$entities the entities to fetch the references for

Methods inherited from CRUDlex\CRUDData
createEmpty(), createFiles(), delete(), deleteFile(), deleteFiles(), executeEvents(), getDefinition(), hydrate(), performOnFiles(), popEvent(), pushEvent(), renderFile(), updateFiles()
Constants inherited from CRUDlex\CRUDData
DELETION_FAILED_EVENT, DELETION_FAILED_STILL_REFERENCED, DELETION_SUCCESS
Properties summary
protected $db

Holds the Doctrine DBAL instance.

Holds the Doctrine DBAL instance.

#
protected $useUUIDs

Flag whether to use UUIDs as primary key.

Flag whether to use UUIDs as primary key.

#
Properties inherited from CRUDlex\CRUDData
$definition, $events, $fileProcessor
CRUDlex API API documentation generated by ApiGen