tflori/orm

just another orm...

View the Project on GitHub tflori/orm

Build Status Test Coverage Maintainability Latest Stable Version Total Downloads

API Reference

ORM

ORM\Dbal

ORM\Dbal\Error

ORM\Dbal\Type

ORM\Entity

ORM\EntityFetcher

ORM\Event

ORM\Exception

ORM\Observer

ORM\QueryBuilder

ORM\Relation

ORM\Testing

ORM\Testing\EntityFetcherMock


ORM\Observer\AbstractObserver

Implements: ORM\ObserverInterface

AbstractObserver for entity events

When a handler returns false it will cancel other event handlers and if applicable stops the execution (saving, inserting, updating and deleting can be canceled).

Methods

ORM\Observer\AbstractObserver::handle

public function handle( ORM\Event $event ): boolean
Handles the $event.

Return false to stop event execution.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$event \ORM\Event  

ORM\Dbal\Type\Boolean

Extends: ORM\Dbal\Type

Boolean data type

Properties

Visibility Name Type Description
protected $dbal ** \ ORM \ Dbal \ Dbal**  

Methods

ORM\Dbal\Type\Boolean::__construct

public function __construct( ORM\Dbal\Dbal $dbal )
Boolean constructor

Visibility: this method is public.

Parameters
Parameter Type Description
$dbal \ORM\Dbal\Dbal  

ORM\Dbal\Type\Boolean::factory

public static function factory(
    ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
Returns a new Type object

This method is only for types covered by mapping. Use fromDefinition instead for custom types.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns static

Parameters
Parameter Type Description
$dbal \ORM\Dbal\Dbal  
$columnDefinition array  

ORM\Dbal\Type\Boolean::fits

public static function fits( array $columnDefinition ): boolean
Check if this type fits to $columnDefinition

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$columnDefinition array  

ORM\Dbal\Type\Boolean::getBoolean

protected function getBoolean( boolean $bool ): string
Get the string representation for boolean

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$bool boolean  

ORM\Dbal\Type\Boolean::validate

public function validate( $value ): boolean|ORM\Dbal\Error
Check if $value is valid for this type

Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error

Parameters
Parameter Type Description
$value mixed  

ORM\BulkInsert

Properties

Visibility Name Type Description
protected $class string  
protected $dbal Dbal \ Dbal  
protected $limit integer  
protected $new array<Entity>  
protected $onSync callable  
protected $synced array<Entity>  
protected $update boolean  
protected $useAutoIncrement boolean  

Methods

ORM\BulkInsert::__construct

public function __construct(
    ORM\Dbal\Dbal $dbal, string $class, integer $limit = 20
)
BulkInsert constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$dbal Dbal\Dbal  
$class string  
$limit integer  

ORM\BulkInsert::add

public function add( ORM\Entity $entities )
Add an entity to the bulk insert.

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$entities Entity  

ORM\BulkInsert::execute

protected function execute()
Executes the bulk insert.

Visibility: this method is protected.

ORM\BulkInsert::finish

public function finish(): array<\ORM\Entity>
Insert the outstanding entities and return all synced objects.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>

ORM\BulkInsert::getLimit

public function getLimit(): integer

Visibility: this method is public.
Returns: this method returns integer

ORM\BulkInsert::limit

public function limit( integer $limit ): $this
Limit the amount of entities inserted at once.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$limit integer  

ORM\BulkInsert::noAutoIncrement

public function noAutoIncrement(): $this
Disable updating the primary key by auto increment.

Caution: If this is disabled updating could cause a IncompletePrimaryKey exception.

Visibility: this method is public.
Returns: this method returns $this

ORM\BulkInsert::noUpdates

public function noUpdates(): $this
Disable updating entities after insert

Visibility: this method is public.
Returns: this method returns $this

ORM\BulkInsert::onSync

public function onSync( callable $callback = null ): $this
Executes $callback after insert

Provides an array of the just inserted entities in first argument.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$callback callable  

ORM\BulkInsert::updateEntities

public function updateEntities(): $this
Enable updating entities after insert

Caution: This option will need to update the primary key by autoincrement which maybe is not supported by your db access layer (DBAL).

Visibility: this method is public.
Returns: this method returns $this

ORM\BulkInsert::useAutoincrement

public function useAutoincrement(): $this
Enable updating the primary keys from autoincrement

Caution: Your db access layer (DBAL) may not support this feature.

Visibility: this method is public.
Returns: this method returns $this


ORM\EntityFetcher\CallableFilter

Implements: ORM\EntityFetcher\FilterInterface

Properties

Visibility Name Type Description
protected $filter    

Methods

ORM\EntityFetcher\CallableFilter::__construct

public function __construct( callable $filter )

Visibility: this method is public.

Parameters
Parameter Type Description
$filter callable  

ORM\EntityFetcher\CallableFilter::apply

public function apply( ORM\EntityFetcher $fetcher ): void
Apply this filter to $fetcher

Visibility: this method is public.
Returns: this method returns void

Parameters
Parameter Type Description
$fetcher \ORM\EntityFetcher  

ORM\Observer\CallbackObserver

Extends: ORM\Observer\AbstractObserver

AbstractObserver for entity events

When a handler returns false it will cancel other event handlers and if applicable stops the execution (saving, inserting, updating and deleting can be canceled).

Properties

Visibility Name Type Description
protected $handlers    

Methods

ORM\Observer\CallbackObserver::handle

public function handle( ORM\Event $event ): boolean
Handles the $event.

Return false to stop event execution.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$event \ORM\Event  

ORM\Observer\CallbackObserver::off

public function off( $event ): $this
Remove all listeners for $event

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$event    

ORM\Observer\CallbackObserver::on

public function on( $event, callable $listener ): $this
Register a new $listener for $event

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$event    
$listener callable  

ORM\Event\Changed

Extends: ORM\Event

Constants

Name Value
NAME 'changed'

Properties

Visibility Name Type Description
protected $attribute string  
protected $data array  
protected $entity ** \ ORM \ Entity**  
protected $newValue mixed  
protected $oldValue mixed  
protected $stopped boolean  

Methods

ORM\Event\Changed::__construct

public function __construct(
    ORM\Entity $entity, $attribute, $oldValue, $newValue
)

Visibility: this method is public.

Parameters
Parameter Type Description
$entity \ORM\Entity  
$attribute    
$oldValue    
$newValue    

ORM\Event\Changed::__get

public function __get( $name )

Visibility: this method is public.

Parameters
Parameter Type Description
$name    

ORM\Event\Changed::stop

public function stop()

Visibility: this method is public.


ORM\Dbal\Column

Describes a column of a database table

Properties

Visibility Name Type Description
protected $columnDefinition array  
protected $dbal Dbal  
protected $hasDefault boolean  
protected $isNullable boolean  
protected static $registeredTypes array<string>  
protected $type TypeInterface  

Methods

ORM\Dbal\Column::__construct

public function __construct( ORM\Dbal\Dbal $dbal, array $columnDefinition )
Column constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$dbal Dbal  
$columnDefinition array  

ORM\Dbal\Column::__get

public function __get( string $name ): mixed
Get attributes from column

Visibility: this method is public.
Returns: this method returns mixed

Parameters
Parameter Type Description
$name string  

ORM\Dbal\Column::getDefault

public function getDefault(): mixed
Get the default value of the column

Visibility: this method is public.
Returns: this method returns mixed

ORM\Dbal\Column::getName

public function getName(): string
Get the name of the column

Visibility: this method is public.
Returns: this method returns string

ORM\Dbal\Column::getNullable

public function getNullable(): boolean
Get the nullable status of the column

Visibility: this method is public.
Returns: this method returns boolean

ORM\Dbal\Column::getRegisteredType

protected static function getRegisteredType( array $columnDefinition ): string
Get the registered type for $columnDefinition

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$columnDefinition array  

ORM\Dbal\Column::getType

public function getType(): ORM\Dbal\Type
Determine and return the type

Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Type

ORM\Dbal\Column::hasDefault

public function hasDefault(): boolean
Check if default value is given

Visibility: this method is public.
Returns: this method returns boolean

ORM\Dbal\Column::isNullable

public function isNullable(): boolean
Check if the column is nullable

Visibility: this method is public.
Returns: this method returns boolean

ORM\Dbal\Column::registerType

public static function registerType( string $type )
Register $type for describe

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$type string The full qualified class name

ORM\Dbal\Column::validate

public function validate( $value ): boolean|ORM\Dbal\Error
Check if $value is valid for this type

Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error

Parameters
Parameter Type Description
$value mixed  

ORM\Dbal\Type\DateTime

Extends: ORM\Dbal\Type

Date and datetime data type

Constants

Name Value
DATE_REGEX '(\+|-)?\d{4,}-\d{2}-\d{2}'
TIME_REGEX '\d{2}:\d{2}:\d{2}(\.\d{1,6})?'
ZONE_REGEX '((\+|-)\d{1,2}(:?\d{2})?|Z)?'

Properties

Visibility Name Type Description
protected $precision integer  
protected $regex string  

Methods

ORM\Dbal\Type\DateTime::__construct

public function __construct(
    integer $precision = null, boolean $dateOnly = false
)
DateTime constructor

Visibility: this method is public.

Parameters
Parameter Type Description
$precision integer  
$dateOnly boolean  

ORM\Dbal\Type\DateTime::factory

public static function factory(
    ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
Returns a new Type object

This method is only for types covered by mapping. Use fromDefinition instead for custom types.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns static

Parameters
Parameter Type Description
$dbal \ORM\Dbal\Dbal  
$columnDefinition array  

ORM\Dbal\Type\DateTime::fits

public static function fits( array $columnDefinition ): boolean
Check if this type fits to $columnDefinition

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$columnDefinition array  

ORM\Dbal\Type\DateTime::getPrecision

public function getPrecision(): integer

Visibility: this method is public.
Returns: this method returns integer

ORM\Dbal\Type\DateTime::validate

public function validate( $value ): boolean|ORM\Dbal\Error
Check if $value is valid for this type

Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error

Parameters
Parameter Type Description
$value mixed  

ORM\Dbal\Dbal

Base class for database abstraction

Properties

Visibility Name Type Description
protected $booleanFalse string  
protected $booleanTrue string  
protected $entityManager ** \ ORM \ EntityManager**  
protected $identifierDivider string  
protected $quotingCharacter string  
protected $transactionCounter integer Number of opened transactions
protected static $typeMapping array  

Methods

ORM\Dbal\Dbal::__construct

public function __construct(
    ORM\EntityManager $entityManager, array $options = array()
)
Dbal constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$entityManager \ORM\EntityManager  
$options array  

ORM\Dbal\Dbal::assertSameType

protected static function assertSameType(
    array<\ORM\Entity> $entities
): boolean

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns boolean
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$entities array<\ORM\Entity>  

ORM\Dbal\Dbal::beginTransaction

public function beginTransaction(): boolean
Begin a transaction or create a savepoint

Visibility: this method is public.
Returns: this method returns boolean

ORM\Dbal\Dbal::buildDeleteStatement

protected function buildDeleteStatement( $table, array $where )

Visibility: this method is protected.

Parameters
Parameter Type Description
$table    
$where array  

ORM\Dbal\Dbal::buildInsert

protected function buildInsert( string $table, array $rows ): string
Build an insert statement for $rows

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$table string  
$rows array  

ORM\Dbal\Dbal::buildSetClause

protected function buildSetClause( array $updates )

Visibility: this method is protected.

Parameters
Parameter Type Description
$updates array  

ORM\Dbal\Dbal::buildUpdateStatement

protected function buildUpdateStatement( $table, array $where, array $updates )

Visibility: this method is protected.

Parameters
Parameter Type Description
$table    
$where array  
$updates array  

ORM\Dbal\Dbal::commit

public function commit( boolean $all = false ): boolean
Commit the current transaction or decrease the savepoint counter

Actually nothing will be committed if there are savepoints. Instead the counter will be decreased and the commited savepoint will still be rolled back when you call rollback afterwards.

Hopefully that gives a hint why save points are no transactions and what the limitations are.

Begin transaction
  updates / inserts for transaction1
  Create savepoint transaction1
    updates / inserts for transaction2
    Create savepoint transaction2
      updates / inserts for transaction3
    <no commit here but you called commit for transaction3>
    updates / inserts for transaction2
  rollback of transaction2 to savepoint of transaction1
  update / inserts for transaction1
commit of transaction1

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$all boolean Commit all opened transactions and savepoints

ORM\Dbal\Dbal::delete

public function delete( string $table, array $where ): integer
Delete rows from $table using $where conditions

Where conditions can be an array of key => value pairs to check for equality or an array of expressions.

Examples: $dbal->delete('someTable', ['id' => 23]) $dbal->delete('user', ['name = \'john\'', 'OR email=\'john.doe@example.com\''])

Tip: Use the query builder to construct where conditions: $em->query('user')->where('name', 'john')->orWhere('email', '...')->delete();

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows

Parameters
Parameter Type Description
$table string The table where to delete rows
$where array An array of where conditions

ORM\Dbal\Dbal::deleteEntity

public function deleteEntity( ORM\Entity $entity ): boolean
Delete $entity from database

This method does not delete from the map - you can still receive the entity via fetch.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entity \ORM\Entity  

ORM\Dbal\Dbal::describe

public function describe(
    string $table
): ORM\Dbal\Table|array<\ORM\Dbal\Column>
Describe a table

Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Table|array<mixed,\ORM\Dbal\Column>
Throws: this method may throw \ORM\Exception\UnsupportedDriver or \ORM\Exception

Parameters
Parameter Type Description
$table string  

ORM\Dbal\Dbal::escapeBoolean

protected function escapeBoolean( boolean $value ): string
Escape a boolean for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value boolean  

ORM\Dbal\Dbal::escapeDateTime

protected function escapeDateTime( DateTime $value ): mixed
Escape a date time object for query

Visibility: this method is protected.
Returns: this method returns mixed

Parameters
Parameter Type Description
$value \DateTime  

ORM\Dbal\Dbal::escapeDouble

protected function escapeDouble( double $value ): string
Escape a double for Query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value double  

ORM\Dbal\Dbal::escapeIdentifier

public function escapeIdentifier( string $identifier ): string
Returns $identifier quoted for use in a sql statement

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$identifier string Identifier to quote

ORM\Dbal\Dbal::escapeInteger

protected function escapeInteger( integer $value ): string
Escape an integer for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value integer  

ORM\Dbal\Dbal::escapeNULL

protected function escapeNULL(): string
Escape NULL for query

Visibility: this method is protected.
Returns: this method returns string

ORM\Dbal\Dbal::escapeString

protected function escapeString( string $value ): string
Escape a string for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value string  

ORM\Dbal\Dbal::escapeValue

public function escapeValue( $value ): string
Returns $value formatted to use in a sql statement.

Visibility: this method is public.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotScalar

Parameters
Parameter Type Description
$value mixed The variable that should be returned in SQL syntax

ORM\Dbal\Dbal::extractParenthesis

protected function extractParenthesis( string $type ): string
Extract content from parenthesis in $type

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$type string  

ORM\Dbal\Dbal::insert

public function insert( $table, array $rows )

Visibility: this method is public.

Parameters
Parameter Type Description
$table    
$rows array  

ORM\Dbal\Dbal::insertAndSync

public function insertAndSync( ORM\Entity $entities ): boolean
Insert $entities and update with default values from database

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns boolean
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Dbal::insertAndSyncWithAutoInc

public function insertAndSyncWithAutoInc(
    ORM\Entity $entities
): integer|boolean
Insert $entities and sync with auto increment primary key

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns integer|boolean
Throws: this method may throw \ORM\Exception\UnsupportedDriver or \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Dbal::insertEntities

public function insertEntities( ORM\Entity $entities ): boolean
Insert $entities into database

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Dbal::normalizeType

protected function normalizeType( string $type ): string
Normalize $type

The type returned by mysql is for example VARCHAR(20) - this function converts it to varchar

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$type string  

ORM\Dbal\Dbal::rollback

public function rollback(): boolean
Rollback the current transaction or save point

Visibility: this method is public.
Returns: this method returns boolean

ORM\Dbal\Dbal::setOption

public function setOption( string $option, $value ): $this
Set $option to $value

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$option string  
$value mixed  

ORM\Dbal\Dbal::syncInserted

protected function syncInserted( ORM\Entity $entities )
Sync the $entities after insert

Visibility: this method is protected.

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Dbal::update

public function update(
    string $table, array $where, array $updates, array $joins = array()
): integer
Update $table using $where to set $updates

Simple usage: update('table', ['id' => 23], ['name' => 'John Doe'])

For advanced queries with parenthesis, joins (if supported from your DBMS) etc. use QueryBuilder:

$em->query('table')
 ->where('birth_date', '>', EM::raw('DATE_SUB(NOW(), INTERVAL 18 YEARS)'))
 ->update(['teenager' => true]);

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of affected rows
Throws: this method may throw \ORM\Exception\UnsupportedDriver

Parameters
Parameter Type Description
$table string The table to update
$where array An array of where conditions
$updates array An array of columns to update
$joins array For internal use from query builder only

ORM\Dbal\Dbal::updateAutoincrement

protected function updateAutoincrement( ORM\Entity $entity, $value )
Update the autoincrement value

Visibility: this method is protected.

Parameters
Parameter Type Description
$entity \ORM\Entity  
$value integer | string  

ORM\DbConfig

Describes a database configuration

Properties

Visibility Name Type Description
public $attributes array PDO attributes
public $host string Hostname or ip address
public $name string Database name or path for sqlite
public $pass string Database password
public $port string Port for DBMS (defaults to 3306 for mysql and 5432 for pgsql)
public $type string Dabase Type (mysql, pgsql or sqlite)
public $user string Database user

Methods

ORM\DbConfig::__construct

public function __construct(
    string $type, string $name, string $user = null, string $pass = null, 
    string $host = null, string $port = null, array $attributes = array()
)
Constructor

The constructor gets all parameters to establish a database connection and configure PDO instance.

Example:

$dbConfig = new DbConfig('mysql', 'my_db', 'my_user', 'my_secret', null, null, [
    \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
]);

Visibility: this method is public.

Parameters
Parameter Type Description
$type string Type of database (currently supported: mysql, pgsql and sqlite)
$name string The name of the database or the path for sqlite
$user string Username to use for connection
$pass string Password
$host string Hostname or IP address - defaults to localhost
$port string Port - default ports (mysql: 3306, pgsql: 5432)
$attributes array Array of PDO attributes

ORM\DbConfig::getDsn

public function getDsn(): string
Get the data source name

Visibility: this method is public.
Returns: this method returns string


ORM\Event\Deleted

Extends: ORM\Event

Constants

Name Value
NAME 'deleted'

Properties

Visibility Name Type Description
protected $data array  
protected $entity ** \ ORM \ Entity**  
protected $stopped boolean  

ORM\Event\Deleting

Extends: ORM\Event

Constants

Name Value
NAME 'deleting'

Properties

Visibility Name Type Description
protected $data array  
protected $entity ** \ ORM \ Entity**  
protected $stopped boolean  

ORM\Entity

Implements:

Definition of an entity

The instance of an entity represents a row of the table and the statics variables and methods describe the database table.

This is the main part where your configuration efforts go. The following properties and methods are well documented in the manual under https://tflori.github.io/orm/entityDefinition.html.

See Also:

Constants

Name Value
OPT_RELATION_CLASS 'class'
OPT_RELATION_CARDINALITY 'cardinality'
OPT_RELATION_REFERENCE 'reference'
OPT_RELATION_OPPONENT 'opponent'
OPT_RELATION_TABLE 'table'

Properties

Visibility Name Type Description
protected static $autoIncrement boolean Whether or not the primary key is auto incremented.
protected static $booted array<boolean>  
protected static $columnAliases array<string> Fixed column names (ignore other settings)
protected static $columnPrefix string A prefix for column names.
protected $data array<mixed> The current data of a row.
protected static $enableValidator boolean Whether or not the validator for this class is enabled.
protected static $enabledValidators array<boolean> Whether or not the validator for a class got enabled during runtime.
protected $entityManager EntityManager The entity manager from which this entity got created
protected static $excludedAttributes array Attributes to hide for toArray method (overruled by $attributes parameter)
protected $exists boolean Whether the entity exists in database
protected static $includedAttributes array Additional attributes to show in toArray method
protected static $namingSchemeAttributes string The naming scheme to use for attributes.
protected static $namingSchemeColumn string The naming scheme to use for column names.
protected static $namingSchemeMethods string The naming scheme to use for method names.
protected static $namingSchemeTable string The naming scheme to use for table names.
protected $originalData array<mixed> The original data of the row.
protected static $primaryKey array<string> | string The variable(s) used for primary key.
protected $relatedObjects array Related objects for getRelated
protected static $relations array | array<Relation> Relation definitions
protected static $tableName string Fixed table name (ignore other settings)
protected static $tableNameTemplate string The template to use to calculate the table name.

Methods

ORM\Entity::__construct

final public function __construct(
    array<mixed> $data = array(), 
    ORM\EntityManager $entityManager = null, boolean $fromDatabase = false
)
Constructor

It calls ::onInit() after initializing $data and $originalData.

Visibility: this method is public.

Parameters
Parameter Type Description
$data array<mixed> The current data
$entityManager EntityManager The EntityManager that created this entity
$fromDatabase boolean Whether or not the data comes from database

ORM\Entity::__get

public function __get( string $attribute ): mixed|null

Visibility: this method is public.
Returns: this method returns mixed|null

Parameters
Parameter Type Description
$attribute string  

See Also:

public function __isset( $attribute ): boolean
Check if a column is defined

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$attribute    

ORM\Entity::__serialize

public function __serialize()

Visibility: this method is public.

ORM\Entity::__set

public function __set( string $attribute, $value )

Visibility: this method is public.

Parameters
Parameter Type Description
$attribute string The variable to change
$value mixed The value to store

See Also:

public function __unserialize( array $data )

Visibility: this method is public.

Parameters
Parameter Type Description
$data array  

ORM\Entity::addRelated

public function addRelated(
    string $relation, array<\ORM\Entity> $entities
)
Add relations for $relation to $entities

This method is only for many-to-many relations.

This method does not take care about already existing relations and will fail hard.

Visibility: this method is public.

Parameters
Parameter Type Description
$relation string  
$entities array<Entity>  

ORM\Entity::boot

protected static function boot()
Boot the class

Static: this method is static.
Visibility: this method is protected.

ORM\Entity::bootIfNotBooted

public static function bootIfNotBooted()
Boot the class if it not already booted

Static: this method is static.
Visibility: this method is public.

ORM\Entity::bootTraits

protected static function bootTraits()
Boot the traits of the class

Static: this method is static.
Visibility: this method is protected.

ORM\Entity::delete

public function delete(): $this
Delete the entity

You might want to implement soft deletes by overriding this method.

Visibility: this method is public.
Returns: this method returns $this

ORM\Entity::deleteRelated

public function deleteRelated(
    string $relation, array<\ORM\Entity> $entities
)
Delete relations for $relation to $entities

This method is only for many-to-many relations.

Visibility: this method is public.

Parameters
Parameter Type Description
$relation string  
$entities array<Entity>  

ORM\Entity::describe

public static function describe(): ORM\Dbal\Table|array<\ORM\Dbal\Column>
Get a description for this table.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Table|array<mixed,\ORM\Dbal\Column>

ORM\Entity::detachObserver

public static function detachObserver( ORM\Observer\AbstractObserver $observer )
Stop observing the class by $observer

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$observer Observer\AbstractObserver  

See Also:

public static function disableValidator( boolean $disable = true )
Disable validator

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$disable boolean  

ORM\Entity::enableValidator

public static function enableValidator( boolean $enable = true )
Enable validator

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$enable boolean  

ORM\Entity::exists

public function exists(): boolean
Returns whether or not the entity exists in database

Visibility: this method is public.
Returns: this method returns boolean

ORM\Entity::fetch

public function fetch(
    string $relation, boolean $getAll = false
): ORM\Entity|array<\ORM\Entity>|ORM\EntityFetcher

For relations with cardinality many it returns an EntityFetcher. Otherwise it returns the entity.

It will throw an error for non owner when the key is incomplete.

Visibility: this method is public.
Returns: this method returns \ORM\Entity|array<mixed,\ORM\Entity>|\ORM\EntityFetcher

Parameters
Parameter Type Description
$relation string The relation to fetch
$getAll boolean  

ORM\Entity::fill

public function fill(
    array $data, boolean $ignoreUnknown = false, boolean $checkMissing = false
)
Fill the entity with $data

When $checkMissing is set to true it also proves that the absent columns are nullable.

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\UnknownColumn or \ORM\Dbal\Error

Parameters
Parameter Type Description
$data array  
$ignoreUnknown boolean  
$checkMissing boolean  

ORM\Entity::generatePrimaryKey

protected function generatePrimaryKey()
Generates a primary key

This method should only be executed from save method.

Visibility: this method is protected.

ORM\Entity::getAttribute

public function getAttribute( string $attribute ): mixed|null
Get the value from $attribute

If there is a custom getter this method get called instead.

Visibility: this method is public.
Returns: this method returns mixed|null

Parameters
Parameter Type Description
$attribute string The variable to get

See Also:

ORM\Entity::getAttributeName

public static function getAttributeName( string $column ): string
Get the column name of $attribute

The column names can not be specified by template. Instead they are constructed by $columnPrefix and enforced to $namingSchemeColumn.

ATTENTION: If your overwrite this method remember that getColumnName(getColumnName($name)) have to be exactly the same as getColumnName($name).

Static: this method is static.
Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$column string  

ORM\Entity::getColumnName

public static function getColumnName( string $attribute ): string
Get the column name of $attribute

The column names can not be specified by template. Instead they are constructed by $columnPrefix and enforced to $namingSchemeColumn.

ATTENTION: If your overwrite this method remember that getColumnName(getColumnName($name)) have to be exactly the same as getColumnName($name).

Static: this method is static.
Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$attribute string  

ORM\Entity::getDirty

public function getDirty(): array
Get an array of attributes that changed

This method works on application level. Meaning it is showing additional attributes defined in ::$includedAttributes and and hiding ::$excludedAttributes.

Visibility: this method is public.
Returns: this method returns array

ORM\Entity::getNamingSchemeColumn

public static function getNamingSchemeColumn(): string

Warning: this method is deprecated. This means that this method will likely be removed in a future version.
Static: this method is static.
Visibility: this method is public.
Returns: this method returns string

ORM\Entity::getNamingSchemeMethods

public static function getNamingSchemeMethods(): string

Warning: this method is deprecated. This means that this method will likely be removed in a future version.
Static: this method is static.
Visibility: this method is public.
Returns: this method returns string

ORM\Entity::getNamingSchemeTable

public static function getNamingSchemeTable(): string

Warning: this method is deprecated. This means that this method will likely be removed in a future version.
Static: this method is static.
Visibility: this method is public.
Returns: this method returns string

ORM\Entity::getPrimaryKey

public function getPrimaryKey(): array
Get the primary key

Visibility: this method is public.
Returns: this method returns array
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey

ORM\Entity::getPrimaryKeyVars

public static function getPrimaryKeyVars(): array
Get the primary key vars

The primary key can consist of multiple columns. You should configure the vars that are translated to these columns.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns array

ORM\Entity::getRelated

public function getRelated( string $relation, boolean $refresh = false ): mixed

The difference between getRelated and fetch is that getRelated stores the fetched entities. To refresh set $refresh to true.

Visibility: this method is public.
Returns: this method returns mixed

Parameters
Parameter Type Description
$relation string  
$refresh boolean  

ORM\Entity::getRelation

public static function getRelation( string $name ): ORM\Relation
Get the definition for $relation

It normalize the short definition form and create a Relation object from it.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\UndefinedRelation

Parameters
Parameter Type Description
$name string  

ORM\Entity::getTableName

public static function getTableName(): string
Get the table name

The table name is constructed by $tableNameTemplate and $namingSchemeTable. It can be overwritten by $tableName.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns string

ORM\Entity::getTableNameTemplate

public static function getTableNameTemplate(): string

Warning: this method is deprecated. This means that this method will likely be removed in a future version.
Static: this method is static.
Visibility: this method is public.
Returns: this method returns string

ORM\Entity::hasLoaded

public function hasLoaded( string $relation ): boolean
Check if $relation got loaded already

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$relation string  

ORM\Entity::hasPrimaryKey

public function hasPrimaryKey(): boolean
Check if the entity has has a complete primary key

Visibility: this method is public.
Returns: this method returns boolean

ORM\Entity::insertEntity

private function insertEntity( boolean $hasPrimaryKey ): ORM\Event\Inserted|null
Insert the row in the database

Visibility: this method is private.
Returns: this method returns \ORM\Event\Inserted|null
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey

Parameters
Parameter Type Description
$hasPrimaryKey boolean  

ORM\Entity::isAutoIncremented

public static function isAutoIncremented(): boolean
Check if the table has a auto increment column

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

ORM\Entity::isDirty

public function isDirty( string $attribute = null ): boolean
Checks if entity or $attribute got changed

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$attribute string Check only this variable or all variables

ORM\Entity::isValid

public function isValid(): boolean|array<\ORM\Dbal\Error>
Check if the current data is valid

Returns boolean true when valid otherwise an array of Errors.

Visibility: this method is public.
Returns: this method returns boolean|array<mixed,\ORM\Dbal\Error>

ORM\Entity::isValidatorEnabled

public static function isValidatorEnabled(): boolean
Check if the validator is enabled

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

ORM\Entity::load

public function load( string $relation ): $this

Nested relations can be loaded by separating them by “.” for example load all articles with comments from a user ($this): $user->load('articles.comments').

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$relation string  

ORM\Entity::observeBy

public static function observeBy(
    $observer = null
): ORM\Observer\CallbackObserver|null
Observe the class using $observer

If AbstractObserver is omitted it returns a new CallbackObserver. Usage example:

$em->observe(User::class)
    ->on('inserted', function (User $user) { ... })
    ->on('deleted', function (User $user) { ... });

For more information about model events please consult the [documentation](https://tflori.github.io/

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Observer\CallbackObserver|null

Parameters
Parameter Type Description
$observer Observer\AbstractObserver | null  

See Also:

public function onChange( string $attribute, $oldValue, $value )
Empty event handler

Get called when something is changed with magic setter.

Visibility: this method is public.

Parameters
Parameter Type Description
$attribute string The variable that got changed.merge(node.inheritedProperties)
$oldValue mixed The old value of the variable
$value mixed The new value of the variable

ORM\Entity::onInit

public function onInit( boolean $new )
Empty event handler

Get called when the entity get initialized.

Visibility: this method is public.

Parameters
Parameter Type Description
$new boolean Whether or not the entity is new or from database

ORM\Entity::postPersist

public function postPersist()
Empty event handler

Get called after the entity got inserted in database.

Visibility: this method is public.

ORM\Entity::postUpdate

public function postUpdate()
Empty event handler

Get called after the entity got updated in database.

Visibility: this method is public.

ORM\Entity::prePersist

public function prePersist()
Empty event handler

Get called before the entity get inserted in database.

Visibility: this method is public.

ORM\Entity::preUpdate

public function preUpdate()
Empty event handler

Get called before the entity get updated in database.

Visibility: this method is public.

ORM\Entity::query

public static function query(): ORM\EntityFetcher
Create an entityFetcher for this entity

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\EntityFetcher

ORM\Entity::registerGlobalFilter

public static function registerGlobalFilter( $filter )
Register a filter that is added to every fetcher for this entity

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$filter string | EntityFetcher\FilterInterface | callable  

ORM\Entity::reset

public function reset( string $attribute = null )
Resets the entity or $attribute to original data

Visibility: this method is public.

Parameters
Parameter Type Description
$attribute string Reset only this variable or all variables

ORM\Entity::resetRelated

public function resetRelated( null $relation = null )
Resets all loaded relations or $relation

Helpful to reduce the size of serializations of the object (for caching, or toArray method etc.)

Visibility: this method is public.

Parameters
Parameter Type Description
$relation null  

ORM\Entity::save

public function save(): $this
Save the entity to EntityManager

Visibility: this method is public.
Returns: this method returns $this
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey

ORM\Entity::serialize

public function serialize(): string
String representation of data

Visibility: this method is public.
Returns: this method returns string

See Also:

ORM\Entity::setAttribute

public function setAttribute( string $attribute, $value ): $this
Set $attribute to $value

Tries to call custom setter before it stores the data directly. If there is a setter the setter needs to store data that should be updated in the database to $data. Do not store data in $originalData as it will not be written and give wrong results for dirty checking.

The onChange event is called after something got changed.

The method throws an error when the validation fails (also when the column does not exist).

Visibility: this method is public.
Returns: this method returns $this
Throws: this method may throw \ORM\Dbal\Error

Parameters
Parameter Type Description
$attribute string The variable to change
$value mixed The value to store

See Also:

ORM\Entity::setEntityManager

public function setEntityManager( ORM\EntityManager $entityManager ): $this

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$entityManager EntityManager  

ORM\Entity::setNamingSchemeColumn

public static function setNamingSchemeColumn( string $namingSchemeColumn )

Warning: this method is deprecated. This means that this method will likely be removed in a future version.
Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$namingSchemeColumn string  

ORM\Entity::setNamingSchemeMethods

public static function setNamingSchemeMethods( string $namingSchemeMethods )

Warning: this method is deprecated. This means that this method will likely be removed in a future version.
Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$namingSchemeMethods string  

ORM\Entity::setNamingSchemeTable

public static function setNamingSchemeTable( string $namingSchemeTable )

Warning: this method is deprecated. This means that this method will likely be removed in a future version.
Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$namingSchemeTable string  

ORM\Entity::setRelated

public function setRelated( string $relation, ORM\Entity $entity = null )
Set $relation to $entity

This method is only for the owner of a relation.

Visibility: this method is public.

Parameters
Parameter Type Description
$relation string  
$entity Entity  

ORM\Entity::setTableNameTemplate

public static function setTableNameTemplate( string $tableNameTemplate )

Warning: this method is deprecated. This means that this method will likely be removed in a future version.
Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$tableNameTemplate string  

ORM\Entity::toArray

public function toArray(
    array $attributes = array(), boolean $includeRelations = true, 
    array $parents = array()
): array
Get an array of the entity

Visibility: this method is public.
Returns: this method returns array

Parameters
Parameter Type Description
$attributes array  
$includeRelations boolean  
$parents array Prevent output containing toArray from parents

ORM\Entity::toArrayPreventRecursion

protected static function toArrayPreventRecursion(
    ORM\Entity $relatedObject, array $parents
)

Static: this method is static.
Visibility: this method is protected.

Parameters
Parameter Type Description
$relatedObject Entity  
$parents array  

ORM\Entity::unserialize

public function unserialize( string $serialized )
Constructs the object

Visibility: this method is public.

Parameters
Parameter Type Description
$serialized string The string representation of data

See Also:

ORM\Entity::updateEntity

private function updateEntity(): ORM\Event\Updated|null
Update the row in the database

Visibility: this method is private.
Returns: this method returns \ORM\Event\Updated|null

ORM\Entity::validate

public static function validate(
    string $attribute, $value
): boolean|ORM\Dbal\Error
Validate $value for $attribute

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error

Parameters
Parameter Type Description
$attribute string  
$value mixed  

ORM\Entity::validateArray

public static function validateArray( array $data ): array
Validate $data

$data has to be an array of $attribute => $value

Static: this method is static.
Visibility: this method is public.
Returns: this method returns array

Parameters
Parameter Type Description
$data array  

ORM\EntityFetcher

Extends: ORM\QueryBuilder\QueryBuilder

Fetch entities from database

If you need more specific queries you write them yourself. If you need just more specific where clause you can pass them to the *where() methods.

Supported:

Properties

Visibility Name Type Description
protected $alias string The alias of the main table
protected $class string | Entity The entity class that we want to fetch
protected $classMapping array<string[]> The class to alias mapping and vise versa
protected $columns array | null Columns to fetch (null is equal to ['*'])
protected $cursor integer The position of the cursor
public static $defaultEntityManager EntityManager The default EntityManager to use to for quoting
protected $eagerLoad array An array or relations that should be loaded
protected $entityManager EntityManager EntityManager to use for quoting
protected $excludedFilters array<string> A list of filters that should not be applied for this fetcher
protected $filters array<EntityFetcher \ FilterInterface> A list of filters to apply additionally
protected $filtersApplied boolean Boolean if the filters where applied
protected static $globalFilters array<EntityFetcher \ FilterInterface[]> Filters that always should be applied for an entity
protected $groupBy array<string> Group by conditions get concatenated with comma
protected $joins array<string> Joins get concatenated with space
protected $limit integer Limit amount of rows
protected $modifier array<string> Modifiers get concatenated with space
protected $offset integer Offset to start from
protected $onClose callable Callback to close the parenthesis
protected $orderBy array<string> Order by conditions get concatenated with comma
protected $parent QueryBuilder \ ParenthesisInterface Parent parenthesis or query
protected $query string | QueryBuilder \ QueryBuilderInterface The query to execute (overwrites other settings)
protected $result ** \ PDOStatement** The result object from PDO
protected $rows array The rows returned
protected $tableName string The table to query
protected $where array<string> Where conditions get concatenated with space

Methods

ORM\EntityFetcher::__construct

public function __construct( ORM\EntityManager $entityManager, $class )
Constructor

Create a select statement for $tableName with an object oriented interface.

It uses static::$defaultEntityManager if $entityManager is not given.

Visibility: this method is public.

Parameters
Parameter Type Description
$entityManager EntityManager EntityManager where to store the fetched entities
$class Entity | string Class to fetch

ORM\EntityFetcher::all

public function all( integer $limit ): array<\ORM\Entity>
Fetch an array of entities

When no $limit is set it fetches all entities in result set.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>

Parameters
Parameter Type Description
$limit integer Maximum number of entities to fetch

ORM\EntityFetcher::andParenthesis

public function andParenthesis(): $this
Add a parenthesis with AND

Visibility: this method is public.
Returns: this method returns $this

ORM\EntityFetcher::andWhere

public function andWhere(
    string $column, $operator = null, string $value = null
): $this
Add a where condition with AND.

QueryBuilderInterface andWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->andWhere('name', '=' , 'John Doe');
$query->andWhere('name = ?', 'John Doe');
$query->andWhere('name', 'John Doe');
$query->andWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\EntityFetcher::applyFilters

protected function applyFilters()
Apply the filters on $this

Visibility: this method is protected.

ORM\EntityFetcher::close

public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Close parenthesis

Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface

ORM\EntityFetcher::column

public function column(
    string $column, array $args = array(), string $alias = ''
): $this
Add $column

Optionally you can provide an expression with question marks as placeholders filled with $args.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression to fetch
$args array Arguments for expression
$alias string Alias for the column

ORM\EntityFetcher::columns

public function columns( array $columns = null ): $this
Set $columns

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$columns array  

ORM\EntityFetcher::convertPlaceholders

protected function convertPlaceholders(
    string $expression, $args, boolean $translateCols = true
): string
Replaces questionmarks in $expression with $args

Additionally this method replaces “ClassName::var” with “alias.col” and “alias.var” with “alias.col” if $translateCols is true (default).

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$expression string Expression with placeholders
$args array | mixed Argument(s) to insert
$translateCols boolean Whether or not column names should be translated

ORM\EntityFetcher::count

public function count(): integer
Get the count of the resulting items

Visibility: this method is public.
Returns: this method returns integer

ORM\EntityFetcher::createRelatedJoin

public function createRelatedJoin( $join, $relation ): $this
Create the join with $join type

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$join    
$relation    

ORM\EntityFetcher::delete

public function delete(): integer
Execute a delete statement on the current table with current where conditions

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows

ORM\EntityFetcher::filter

public function filter( $filter ): $this
Apply an additional $filter before executing

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$filter string | EntityFetcher\FilterInterface | callable  

ORM\EntityFetcher::fullJoin

public function fullJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Full (outer) join $tableName with $options

When no expression got provided self get returned. If you want to get a parenthesis the parameter empty can be set to false.

ATTENTION: here the default value of empty got changed - defaults to yes

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\EntityFetcher::getDefaultOperator

private function getDefaultOperator( $value ): string
Get the default operator for $value

Arrays use IN by default - all others use =

Visibility: this method is private.
Returns: this method returns string

Parameters
Parameter Type Description
$value mixed The value to determine the operator

ORM\EntityFetcher::getEntityManager

public function getEntityManager(): ORM\EntityManager

Visibility: this method is public.
Returns: this method returns \ORM\EntityManager

ORM\EntityFetcher::getExpression

public function getExpression(): string
Get the expression

Returns the complete expression inside this parenthesis.

Visibility: this method is public.
Returns: this method returns string

ORM\EntityFetcher::getGlobalFilters

public static function getGlobalFilters( string $class ): array
Get the filters registered for $class

A filter can be registered for the super class too.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns array

Parameters
Parameter Type Description
$class string  

ORM\EntityFetcher::getQuery

public function getQuery(): string
Get the query / select statement

Builds the statement from current where conditions, joins, columns and so on.

Visibility: this method is public.
Returns: this method returns string

ORM\EntityFetcher::getStatement

protected function getStatement(): PDOStatement|boolean
Query database and return result

Queries the database with current query and returns the resulted PDOStatement.

If query failed it returns false. It also stores this failed result and to change the query afterwards will not change the result.

Visibility: this method is protected.
Returns: this method returns \PDOStatement|boolean

ORM\EntityFetcher::getTableAndAlias

protected function getTableAndAlias( string $class, string $alias = '' ): array
Get the table name and alias for a class

Visibility: this method is protected.
Returns: this method returns array
Response description: [$table, $alias]

Parameters
Parameter Type Description
$class string  
$alias string  

ORM\EntityFetcher::groupBy

public function groupBy( string $column, array $args = array() ): $this
Group By $column

Optionally you can provide an expression in $column with question marks as placeholders.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression for groups
$args array Arguments for expression

ORM\EntityFetcher::insert

public function insert( array $rows ): integer
Execute an insert statement on the current table

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of inserted rows

Parameters
Parameter Type Description
$rows array  

ORM\EntityFetcher::join

public function join(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
(Inner) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\EntityFetcher::joinRelated

public function joinRelated( $relation ): $this
Join $relation

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$relation    

ORM\EntityFetcher::leftJoin

public function leftJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Left (outer) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\EntityFetcher::leftJoinRelated

public function leftJoinRelated( $relation ): $this
Left outer join $relation

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$relation    

ORM\EntityFetcher::limit

public function limit( integer $limit ): $this
Set $limit

Limits the amount of rows fetched from database.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$limit integer The limit to set

ORM\EntityFetcher::modifier

public function modifier( string $modifier ): $this
Add $modifier

Add query modifiers such as SQL_CALC_FOUND_ROWS or DISTINCT.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$modifier string  

ORM\EntityFetcher::normalizeFilter

protected static function normalizeFilter(
    $filter
): ORM\EntityFetcher\FilterInterface
Converts callables into a CallableFilter and class names into instances

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns \ORM\EntityFetcher\FilterInterface
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$filter string | EntityFetcher\FilterInterface | callable  

ORM\EntityFetcher::offset

public function offset( integer $offset ): $this
Set $offset

Changes the offset (only with limit) where fetching starts in the query.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$offset integer The offset to set

ORM\EntityFetcher::one

public function one(): ORM\Entity
Fetch one entity

If there is no more entity in the result set it returns null.

Visibility: this method is public.
Returns: this method returns \ORM\Entity

ORM\EntityFetcher::orderBy

public function orderBy(
    string $column, string $direction = self::DIRECTION_ASCENDING, 
    array $args = array()
): $this
Order By $column in $direction

Optionally you can provide an expression in $column with question marks as placeholders.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression for order
$direction string Direction (default: ASC)
$args array Arguments for expression

ORM\EntityFetcher::orParenthesis

public function orParenthesis(): $this
Add a parenthesis with OR

Visibility: this method is public.
Returns: this method returns $this

ORM\EntityFetcher::orWhere

public function orWhere(
    string $column, $operator = null, string $value = null
): $this
Add a where condition with OR.

QueryBuilderInterface orWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->orWhere('name', '=' , 'John Doe');
$query->orWhere('name = ?', 'John Doe');
$query->orWhere('name', 'John Doe');
$query->orWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\EntityFetcher::orWhereIn

public function orWhereIn( $column, array $values ): $this
Add a where in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\EntityFetcher::orWhereNotIn

public function orWhereNotIn( $column, array $values ): $this
Add a where not in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\EntityFetcher::parenthesis

public function parenthesis(): $this
Alias for andParenthesis

Visibility: this method is public.
Returns: this method returns $this

ORM\EntityFetcher::registerGlobalFilter

public static function registerGlobalFilter( $class, $filter )
Register $filter globally for $class

A registered filter will be applied in all entity fetchers for the class if not excluded by $fetcher->withoutFilter(Filter::class).

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$class    
$filter string | EntityFetcher\FilterInterface | callable  

ORM\EntityFetcher::reset

public function reset(): $this
Reset the position of the cursor to the first row

Visibility: this method is public.
Returns: this method returns $this

ORM\EntityFetcher::rightJoin

public function rightJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Right (outer) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\EntityFetcher::setFetchMode

public function setFetchMode(
    integer $mode, $classNameObject = null, array $constructorArgs = null
): $this
Proxy to PDOStatement::setFetchMode()

Please note that this will execute the query - further modifications will not have any effect.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$mode integer one of the PDO::FETCH_ constants
$classNameObject integer | string | object class (FETCH_CLASS), column number (FETCH_COLUMN), object (FETCH_INTO)
$constructorArgs array arguments to pass to the constructor (FETCH_CLASS)

See Also:

public function setQuery( $query, array $args = null ): $this
Set a raw query or use different QueryBuilder

For easier use and against sql injection it allows question mark placeholders.

Please be aware that this query is not touched at all and neither filters nor where conditions are applied.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$query string | QueryBuilder\QueryBuilderInterface Raw query string or a QueryBuilderInterface
$args array The arguments for placeholders

ORM\EntityFetcher::toClassAndAlias

private function toClassAndAlias( array $match ): array
Get class and alias by the match from translateColumn

Visibility: this method is private.
Returns: this method returns array
Response description: [$class, $alias]
Throws: this method may throw \ORM\Exception\NotJoined

Parameters
Parameter Type Description
$match array  

ORM\EntityFetcher::translateColumn

protected function translateColumn( string $expression ): string
Translate attribute names in an expression to their column names

Visibility: this method is protected.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotJoined

Parameters
Parameter Type Description
$expression string  

ORM\EntityFetcher::update

public function update( array $updates ): integer
Execute an update statement for the current query

NOTE: not all drivers support UPDATE with JOIN (or FROM). Has to be implemented in the database abstraction layer.

$updates should be an array which columns to update with what value. Use expressions to bypass escaping.

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of affected rows

Parameters
Parameter Type Description
$updates array An array of columns to update

ORM\EntityFetcher::where

public function where( string $column, $operator = null, $value = null ): $this
Alias for andWhere

QueryBuilderInterface where($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->where('name', '=' , 'John Doe');
$query->where('name = ?', 'John Doe');
$query->where('name', 'John Doe');
$query->where('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator mixed Operator, value or array of values
$value mixed Value (required when used with operator)

See Also:

public function whereIn( $column, array $values ): $this
Add a where in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\EntityFetcher::whereNotIn

public function whereNotIn( $column, array $values ): $this
Add a where not in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\EntityFetcher::wherePrefix

private function wherePrefix( string $bool ): string
Get the prefix for a where condition or empty if not needed

Visibility: this method is private.
Returns: this method returns string

Parameters
Parameter Type Description
$bool string The prefix to use (‘AND’ or ‘OR’)

ORM\EntityFetcher::with

public function with( string $relations ): $this
Load $relations after all objects are loaded

The relations are only loaded after you execute ->all()

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$relations string  

ORM\EntityFetcher::withoutFilter

public function withoutFilter( string $filterClass ): $this
Exclude $filterClass for this fetcher

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$filterClass string  

ORM\Testing\EntityFetcherMock

Extends: ORM\EntityFetcher

Fetch entities from database

If you need more specific queries you write them yourself. If you need just more specific where clause you can pass them to the *where() methods.

Supported:

Properties

Visibility Name Type Description
protected $alias string The alias of the main table
protected $class string | \ ORM \ Entity The entity class that we want to fetch
protected $classMapping array<string[]> The class to alias mapping and vise versa
protected $columns array | null Columns to fetch (null is equal to ['*'])
protected $currentResult array  
protected $cursor integer The position of the cursor
public static $defaultEntityManager ** \ ORM \ EntityManager** The default EntityManager to use to for quoting
protected $eagerLoad array An array or relations that should be loaded
public $entityManager EntityManagerMock  
protected $excludedFilters array<string> A list of filters that should not be applied for this fetcher
protected $filters array< \ ORM \ EntityFetcher \ FilterInterface> A list of filters to apply additionally
protected $filtersApplied boolean Boolean if the filters where applied
protected static $globalFilters array< \ ORM \ EntityFetcher \ FilterInterface[]> Filters that always should be applied for an entity
protected $groupBy array<string> Group by conditions get concatenated with comma
protected $joins array<string> Joins get concatenated with space
protected $limit integer Limit amount of rows
protected $modifier array<string> Modifiers get concatenated with space
protected $offset integer Offset to start from
protected $onClose callable Callback to close the parenthesis
protected $orderBy array<string> Order by conditions get concatenated with comma
protected $parent ** \ ORM \ QueryBuilder \ ParenthesisInterface** Parent parenthesis or query
protected $query string | \ ORM \ QueryBuilder \ QueryBuilderInterface The query to execute (overwrites other settings)
protected $result ** \ PDOStatement** The result object from PDO
protected $rows array The rows returned
protected $tableName string The table to query
protected $where array<string> Where conditions get concatenated with space

Methods

ORM\Testing\EntityFetcherMock::__construct

public function __construct(
    callable $onClose, ORM\QueryBuilder\ParenthesisInterface $parent
)
Constructor

Create a parenthesis inside another parenthesis or a query.

Visibility: this method is public.

Parameters
Parameter Type Description
$onClose callable Callable that gets executed when the parenthesis get closed
$parent \ORM\QueryBuilder\ParenthesisInterface Parent where createWhereCondition get executed

ORM\Testing\EntityFetcherMock::all

public function all(): mixed|null
Get all rows from the query result

Please note that this will execute the query - further modifications will not have any effect.

If the query fails you should get an exception. Anyway if we couldn’t get a result or there are no rows it returns an empty array.

Visibility: this method is public.
Returns: this method returns mixed|null

ORM\Testing\EntityFetcherMock::andParenthesis

public function andParenthesis(): $this
Add a parenthesis with AND

Visibility: this method is public.
Returns: this method returns $this

ORM\Testing\EntityFetcherMock::andWhere

public function andWhere(
    string $column, $operator = null, string $value = null
): $this
Add a where condition with AND.

QueryBuilderInterface andWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->andWhere('name', '=' , 'John Doe');
$query->andWhere('name = ?', 'John Doe');
$query->andWhere('name', 'John Doe');
$query->andWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\Testing\EntityFetcherMock::applyFilters

protected function applyFilters()
Apply the filters on $this

Visibility: this method is protected.

ORM\Testing\EntityFetcherMock::close

public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Close parenthesis

Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface

ORM\Testing\EntityFetcherMock::column

public function column(
    string $column, array $args = array(), string $alias = ''
): $this
Add $column

Optionally you can provide an expression with question marks as placeholders filled with $args.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression to fetch
$args array Arguments for expression
$alias string Alias for the column

ORM\Testing\EntityFetcherMock::columns

public function columns( array $columns = null ): $this
Set $columns

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$columns array  

ORM\Testing\EntityFetcherMock::convertPlaceholders

protected function convertPlaceholders( string $expression, $args ): string
Replaces question marks in $expression with $args

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$expression string Expression with placeholders
$args array | mixed Arguments for placeholders

ORM\Testing\EntityFetcherMock::count

public function count(): integer
Get the count of the resulting items

Visibility: this method is public.
Returns: this method returns integer

ORM\Testing\EntityFetcherMock::createRelatedJoin

public function createRelatedJoin( $join, $relation ): $this
Create the join with $join type

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$join    
$relation    

ORM\Testing\EntityFetcherMock::delete

public function delete(): integer
Execute a delete statement on the current table with current where conditions

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows

ORM\Testing\EntityFetcherMock::filter

public function filter( $filter ): $this
Apply an additional $filter before executing

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$filter string | \ORM\EntityFetcher\FilterInterface | callable  

ORM\Testing\EntityFetcherMock::fullJoin

public function fullJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Full (outer) join $tableName with $options

When no expression got provided self get returned. If you want to get a parenthesis the parameter empty can be set to false.

ATTENTION: here the default value of empty got changed - defaults to yes

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\Testing\EntityFetcherMock::getDefaultOperator

private function getDefaultOperator( $value ): string
Get the default operator for $value

Arrays use IN by default - all others use =

Visibility: this method is private.
Returns: this method returns string

Parameters
Parameter Type Description
$value mixed The value to determine the operator

ORM\Testing\EntityFetcherMock::getEntityManager

public function getEntityManager(): ORM\EntityManager

Visibility: this method is public.
Returns: this method returns \ORM\EntityManager

ORM\Testing\EntityFetcherMock::getExpression

public function getExpression(): string
Get the expression

Returns the complete expression inside this parenthesis.

Visibility: this method is public.
Returns: this method returns string

ORM\Testing\EntityFetcherMock::getGlobalFilters

public static function getGlobalFilters( string $class ): array
Get the filters registered for $class

A filter can be registered for the super class too.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns array

Parameters
Parameter Type Description
$class string  

ORM\Testing\EntityFetcherMock::getQuery

public function getQuery(): string
Get the query / select statement

Builds the statement from current where conditions, joins, columns and so on.

Visibility: this method is public.
Returns: this method returns string

ORM\Testing\EntityFetcherMock::getStatement

protected function getStatement(): PDOStatement|boolean
Query database and return result

Queries the database with current query and returns the resulted PDOStatement.

If query failed it returns false. It also stores this failed result and to change the query afterwards will not change the result.

Visibility: this method is protected.
Returns: this method returns \PDOStatement|boolean

ORM\Testing\EntityFetcherMock::getTableAndAlias

protected function getTableAndAlias( string $class, string $alias = '' ): array
Get the table name and alias for a class

Visibility: this method is protected.
Returns: this method returns array
Response description: [$table, $alias]

Parameters
Parameter Type Description
$class string  
$alias string  

ORM\Testing\EntityFetcherMock::groupBy

public function groupBy( string $column, array $args = array() ): $this
Group By $column

Optionally you can provide an expression in $column with question marks as placeholders.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression for groups
$args array Arguments for expression

ORM\Testing\EntityFetcherMock::insert

public function insert( array $rows ): integer
Execute an insert statement on the current table

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of inserted rows

Parameters
Parameter Type Description
$rows array  

ORM\Testing\EntityFetcherMock::join

public function join(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
(Inner) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\Testing\EntityFetcherMock::joinRelated

public function joinRelated( $relation ): $this
Join $relation

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$relation    

ORM\Testing\EntityFetcherMock::leftJoin

public function leftJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Left (outer) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\Testing\EntityFetcherMock::leftJoinRelated

public function leftJoinRelated( $relation ): $this
Left outer join $relation

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$relation    

ORM\Testing\EntityFetcherMock::limit

public function limit( integer $limit ): $this
Set $limit

Limits the amount of rows fetched from database.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$limit integer The limit to set

ORM\Testing\EntityFetcherMock::modifier

public function modifier( string $modifier ): $this
Add $modifier

Add query modifiers such as SQL_CALC_FOUND_ROWS or DISTINCT.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$modifier string  

ORM\Testing\EntityFetcherMock::normalizeFilter

protected static function normalizeFilter(
    $filter
): ORM\EntityFetcher\FilterInterface
Converts callables into a CallableFilter and class names into instances

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns \ORM\EntityFetcher\FilterInterface
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$filter string | \ORM\EntityFetcher\FilterInterface | callable  

ORM\Testing\EntityFetcherMock::offset

public function offset( integer $offset ): $this
Set $offset

Changes the offset (only with limit) where fetching starts in the query.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$offset integer The offset to set

ORM\Testing\EntityFetcherMock::one

public function one(): ORM\Entity
Fetch one entity

If there is no more entity in the result set it returns null.

Visibility: this method is public.
Returns: this method returns \ORM\Entity

ORM\Testing\EntityFetcherMock::orderBy

public function orderBy(
    string $column, string $direction = self::DIRECTION_ASCENDING, 
    array $args = array()
): $this
Order By $column in $direction

Optionally you can provide an expression in $column with question marks as placeholders.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression for order
$direction string Direction (default: ASC)
$args array Arguments for expression

ORM\Testing\EntityFetcherMock::orParenthesis

public function orParenthesis(): $this
Add a parenthesis with OR

Visibility: this method is public.
Returns: this method returns $this

ORM\Testing\EntityFetcherMock::orWhere

public function orWhere(
    string $column, $operator = null, string $value = null
): $this
Add a where condition with OR.

QueryBuilderInterface orWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->orWhere('name', '=' , 'John Doe');
$query->orWhere('name = ?', 'John Doe');
$query->orWhere('name', 'John Doe');
$query->orWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\Testing\EntityFetcherMock::orWhereIn

public function orWhereIn( $column, array $values ): $this
Add a where in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\Testing\EntityFetcherMock::orWhereNotIn

public function orWhereNotIn( $column, array $values ): $this
Add a where not in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\Testing\EntityFetcherMock::parenthesis

public function parenthesis(): $this
Alias for andParenthesis

Visibility: this method is public.
Returns: this method returns $this

ORM\Testing\EntityFetcherMock::registerGlobalFilter

public static function registerGlobalFilter( $class, $filter )
Register $filter globally for $class

A registered filter will be applied in all entity fetchers for the class if not excluded by $fetcher->withoutFilter(Filter::class).

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$class    
$filter string | \ORM\EntityFetcher\FilterInterface | callable  

ORM\Testing\EntityFetcherMock::reset

public function reset(): $this
Reset the position of the cursor to the first row

Visibility: this method is public.
Returns: this method returns $this

ORM\Testing\EntityFetcherMock::rightJoin

public function rightJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Right (outer) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\Testing\EntityFetcherMock::setFetchMode

public function setFetchMode(
    integer $mode, $classNameObject = null, array $constructorArgs = null
): $this
Proxy to PDOStatement::setFetchMode()

Please note that this will execute the query - further modifications will not have any effect.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$mode integer one of the PDO::FETCH_ constants
$classNameObject integer | string | object class (FETCH_CLASS), column number (FETCH_COLUMN), object (FETCH_INTO)
$constructorArgs array arguments to pass to the constructor (FETCH_CLASS)

See Also:

public function setQuery( $query, array $args = null ): $this
Set a raw query or use different QueryBuilder

For easier use and against sql injection it allows question mark placeholders.

Please be aware that this query is not touched at all and neither filters nor where conditions are applied.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$query string | \ORM\QueryBuilder\QueryBuilderInterface Raw query string or a QueryBuilderInterface
$args array The arguments for placeholders

ORM\Testing\EntityFetcherMock::toClassAndAlias

private function toClassAndAlias( array $match ): array
Get class and alias by the match from translateColumn

Visibility: this method is private.
Returns: this method returns array
Response description: [$class, $alias]
Throws: this method may throw \ORM\Exception\NotJoined

Parameters
Parameter Type Description
$match array  

ORM\Testing\EntityFetcherMock::translateColumn

protected function translateColumn( string $expression ): string
Translate attribute names in an expression to their column names

Visibility: this method is protected.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotJoined

Parameters
Parameter Type Description
$expression string  

ORM\Testing\EntityFetcherMock::update

public function update( array $updates ): integer
Execute an update statement for the current query

NOTE: not all drivers support UPDATE with JOIN (or FROM). Has to be implemented in the database abstraction layer.

$updates should be an array which columns to update with what value. Use expressions to bypass escaping.

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of affected rows

Parameters
Parameter Type Description
$updates array An array of columns to update

ORM\Testing\EntityFetcherMock::where

public function where( string $column, $operator = null, $value = null ): $this
Alias for andWhere

QueryBuilderInterface where($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->where('name', '=' , 'John Doe');
$query->where('name = ?', 'John Doe');
$query->where('name', 'John Doe');
$query->where('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator mixed Operator, value or array of values
$value mixed Value (required when used with operator)

See Also:

public function whereIn( $column, array $values ): $this
Add a where in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\Testing\EntityFetcherMock::whereNotIn

public function whereNotIn( $column, array $values ): $this
Add a where not in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\Testing\EntityFetcherMock::wherePrefix

private function wherePrefix( string $bool ): string
Get the prefix for a where condition or empty if not needed

Visibility: this method is private.
Returns: this method returns string

Parameters
Parameter Type Description
$bool string The prefix to use (‘AND’ or ‘OR’)

ORM\Testing\EntityFetcherMock::with

public function with( string $relations ): $this
Load $relations after all objects are loaded

The relations are only loaded after you execute ->all()

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$relations string  

ORM\Testing\EntityFetcherMock::withoutFilter

public function withoutFilter( string $filterClass ): $this
Exclude $filterClass for this fetcher

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$filterClass string  

ORM\EntityManager

The EntityManager that manages the instances of Entities.

Constants

Name Value
OPT_CONNECTION 'connection'
OPT_TABLE_NAME_TEMPLATE 'tableNameTemplate'
OPT_NAMING_SCHEME_TABLE 'namingSchemeTable'
OPT_NAMING_SCHEME_COLUMN 'namingSchemeColumn'
OPT_NAMING_SCHEME_METHODS 'namingSchemeMethods'
OPT_NAMING_SCHEME_ATTRIBUTE 'namingSchemeAttribute'
OPT_QUOTING_CHARACTER 'quotingChar'
OPT_IDENTIFIER_DIVIDER 'identifierDivider'
OPT_BOOLEAN_TRUE 'true'
OPT_BOOLEAN_FALSE 'false'
OPT_DBAL_CLASS 'dbalClass'
OPT_MYSQL_BOOLEAN_TRUE 'mysqlTrue'
OPT_MYSQL_BOOLEAN_FALSE 'mysqlFalse'
OPT_SQLITE_BOOLEAN_TRUE 'sqliteTrue'
OPT_SQLITE_BOOLEAN_FALSE 'sqliteFalse'
OPT_PGSQL_BOOLEAN_TRUE 'pgsqlTrue'
OPT_PGSQL_BOOLEAN_FALSE 'pgsqlFalse'

Properties

Visibility Name Type Description
protected $bulkInserts array<BulkInsert> Classes forcing bulk insert
protected $connection ** \ PDO | callable | DbConfig** Connection to database
protected $dbal Dbal \ Dbal The Database Abstraction Layer
protected $descriptions array<Dbal \ Table> | array<Dbal \ Column[]> Already fetched column descriptions
protected static $emMapping EntityManager[string] | EntityManager[string][string] Mapping for EntityManager instances
protected $map array<Entity[]> The Entity map
protected $namer Namer The Namer instance
protected $observers array<ObserverInterface[]>  
protected $options array The options set for this instance
protected static $resolver callable  

Methods

ORM\EntityManager::__construct

public function __construct( array $options = array() )
Constructor

Visibility: this method is public.

Parameters
Parameter Type Description
$options array Options for the new EntityManager

ORM\EntityManager::beginTransaction

public function beginTransaction(): boolean
Begin a transaction or create a savepoint

Visibility: this method is public.
Returns: this method returns boolean

ORM\EntityManager::buildChecksum

protected static function buildChecksum( array $primaryKey ): string
Build a checksum from $primaryKey

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$primaryKey array  

ORM\EntityManager::buildPrimaryKey

protected static function buildPrimaryKey( $class, array $primaryKey ): array
Builds the primary key with column names as keys

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns array
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey

Parameters
Parameter Type Description
$class string | Entity  
$primaryKey array  

ORM\EntityManager::commit

public function commit( boolean $all = false ): boolean
Commit the current transaction or decrease the savepoint counter

Actually nothing will be committed if there are savepoints. Instead the counter will be decreased and the commited savepoint will still be rolled back when you call rollback afterwards.

Hopefully that gives a hint why save points are no transactions and what the limitations are.

Begin transaction
  updates / inserts for transaction1
  Create savepoint transaction1
    updates / inserts for transaction2
    Create savepoint transaction2
      updates / inserts for transaction3
    <no commit here but you called commit for transaction3>
    updates / inserts for transaction2
  rollback of transaction2 to savepoint of transaction1
  update / inserts for transaction1
commit of transaction1

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$all boolean Commit all opened transactions and savepoints

ORM\EntityManager::defineForNamespace

public function defineForNamespace( $nameSpace ): $this
Define $this EntityManager as the default EntityManager for $nameSpace

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$nameSpace    

ORM\EntityManager::defineForParent

public function defineForParent( $class ): $this
Define $this EntityManager as the default EntityManager for subClasses of $class

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$class    

ORM\EntityManager::delete

public function delete( ORM\Entity $entity ): boolean
Delete $entity from database

This method does not delete from the map - you can still receive the entity via fetch.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entity Entity  

ORM\EntityManager::describe

public function describe(
    string $table
): array<\ORM\Dbal\Column>|ORM\Dbal\Table
Returns an array of columns from $table.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Dbal\Column>|\ORM\Dbal\Table

Parameters
Parameter Type Description
$table string  

ORM\EntityManager::detach

public function detach( ORM\ObserverInterface $observer, $from = null ): boolean
Detach $observer from all classes

If the observer is attached to multiple classes all are removed except the optional parameter $from defines from which class to remove the $observer.

Returns whether or not an observer got detached.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$observer ObserverInterface  
$from string | null  

ORM\EntityManager::eagerLoad

public function eagerLoad( string $relation, ORM\Entity $entities )
Load the $relation on all $entities with the least amount of queries

$relation can be nested by dividing them with a dot.

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\UndefinedRelation

Parameters
Parameter Type Description
$relation string  
$entities Entity  

ORM\EntityManager::escapeIdentifier

public function escapeIdentifier( string $identifier ): string
Returns $identifier quoted for use in a sql statement

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$identifier string Identifier to quote

ORM\EntityManager::escapeValue

public function escapeValue( $value ): string
Returns $value formatted to use in a sql statement.

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$value mixed The variable that should be returned in SQL syntax

ORM\EntityManager::fetch

public function fetch(
    string $class, $primaryKey = null
): ORM\Entity|ORM\EntityFetcher
Fetch one or more entities

With $primaryKey it tries to find this primary key in the entity map (carefully: mostly the database returns a string and we do not convert them). If there is no entity in the entity map it tries to fetch the entity from the database. The return value is then null (not found) or the entity.

Without $primaryKey it creates an entityFetcher and returns this.

Visibility: this method is public.
Returns: this method returns \ORM\Entity|\ORM\EntityFetcher
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey or \ORM\Exception\NoEntity

Parameters
Parameter Type Description
$class string The entity class you want to fetch
$primaryKey mixed The primary key of the entity you want to fetch

ORM\EntityManager::finishBulkInserts

public function finishBulkInserts( $class ): array<\ORM\Entity>
Finish the bulk insert for $class.

Returns an array of entities added.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>

Parameters
Parameter Type Description
$class    

ORM\EntityManager::fire

public function fire( ORM\Event $event ): boolean
Fire $event on $entity

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$event Event  

ORM\EntityManager::getConnection

public function getConnection(): PDO
Get the pdo connection.

Visibility: this method is public.
Returns: this method returns \PDO
Throws: this method may throw \ORM\Exception\NoConnection or \ORM\Exception\NoConnection

ORM\EntityManager::getDbal

public function getDbal(): ORM\Dbal\Dbal
Get the Database Abstraction Layer

Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Dbal

ORM\EntityManager::getInstance

public static function getInstance( string $class = null ): ORM\EntityManager
Get an instance of the EntityManager.

If no class is given it gets $class from backtrace.

It first tries to get the EntityManager for the Namespace of $class, then for the parents of $class. If no EntityManager is found it returns the last created EntityManager (null if no EntityManager got created).

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\EntityManager

Parameters
Parameter Type Description
$class string  

ORM\EntityManager::getInstanceByNameSpace

private static function getInstanceByNameSpace( $class ): ORM\EntityManager
Get the instance by NameSpace mapping

Static: this method is static.
Visibility: this method is private.
Returns: this method returns \ORM\EntityManager

Parameters
Parameter Type Description
$class    

ORM\EntityManager::getInstanceByParent

private static function getInstanceByParent( $class ): ORM\EntityManager
Get the instance by Parent class mapping

Static: this method is static.
Visibility: this method is private.
Returns: this method returns \ORM\EntityManager

Parameters
Parameter Type Description
$class    

ORM\EntityManager::getNamer

public function getNamer(): ORM\Namer
Get the Namer instance

Visibility: this method is public.
Returns: this method returns \ORM\Namer

ORM\EntityManager::getOption

public function getOption( $option ): mixed
Get $option

Visibility: this method is public.
Returns: this method returns mixed

Parameters
Parameter Type Description
$option    

ORM\EntityManager::has

public function has( $entity, $primaryKey = null ): boolean
Check if the entity map has $entity

If you want to know if the entity already exists in the map use this method.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entity Entity | string  
$primaryKey mixed  

ORM\EntityManager::map

public function map(
    ORM\Entity $entity, boolean $update = false, string $class = null
): ORM\Entity
Map $entity in the entity map

Returns the given entity or an entity that previously got mapped. This is useful to work in every function with the same object.

$user = $enitityManager->map(new User(['id' => 42]));

Visibility: this method is public.
Returns: this method returns \ORM\Entity

Parameters
Parameter Type Description
$entity Entity  
$update boolean Update the entity map
$class string Overwrite the class

ORM\EntityManager::observe

public function observe(
    string $class, $observer = null
): ORM\Observer\CallbackObserver|null
Observe $class using $observer

If AbstractObserver is omitted it returns a new CallbackObserver. Usage example:

$em->observe(User::class)
    ->on('inserted', function (User $user) { ... })
    ->on('deleted', function (User $user) { ... });

For more information about model events please consult the [documentation](https://tflori.github.io/

Visibility: this method is public.
Returns: this method returns \ORM\Observer\CallbackObserver|null
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$class string  
$observer ObserverInterface | null  

ORM\EntityManager::query

public function query(
    string $table, string $alias = ''
): ORM\QueryBuilder\QueryBuilder
Get a query builder for $table

Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilder

Parameters
Parameter Type Description
$table string  
$alias string  

ORM\EntityManager::raw

public static function raw( string $expression ): ORM\Dbal\Expression
Create a raw expression from $expression to disable escaping

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Expression

Parameters
Parameter Type Description
$expression string  

ORM\EntityManager::rollback

public function rollback(): boolean
Rollback the current transaction or save point

Visibility: this method is public.
Returns: this method returns boolean

ORM\EntityManager::setConnection

public function setConnection( $connection )
Add connection after instantiation

The connection can be an array of parameters for DbConfig::__construct(), a callable function that returns a PDO instance, an instance of DbConfig or a PDO instance itself.

When it is not a PDO instance the connection get established on first use.

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$connection mixed A configuration for (or a) PDO instance

ORM\EntityManager::setOption

public function setOption( string $option, $value ): $this
Set $option to $value

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$option string One of OPT_* constants
$value mixed  

ORM\EntityManager::setResolver

public static function setResolver( callable $resolver )
Overwrite the functionality of ::getInstance($class) by $resolver($class)

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$resolver callable  

ORM\EntityManager::sync

public function sync( ORM\Entity $entity, boolean $reset = false ): boolean
Synchronizing $entity with database

If $reset is true it also calls reset() on $entity.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entity Entity  
$reset boolean Reset entities current data

ORM\EntityManager::useBulkInserts

public function useBulkInserts(
    string $class, integer $limit = 20
): ORM\BulkInsert
Force $class to use bulk insert.

At the end you should call finish bulk insert otherwise you may loose data.

Visibility: this method is public.
Returns: this method returns \ORM\BulkInsert

Parameters
Parameter Type Description
$class string  
$limit integer Maximum number of rows per insert

ORM\Testing\EntityManagerMock

Extends: ORM\EntityManager

The EntityManager that manages the instances of Entities.

Properties

Visibility Name Type Description
protected $bulkInserts array< \ ORM \ BulkInsert> Classes forcing bulk insert
protected $connection ** \ PDO | callable | \ ORM \ DbConfig** Connection to database
protected $dbal ** \ ORM \ Dbal \ Dbal** The Database Abstraction Layer
protected $descriptions array< \ ORM \ Dbal \ Table> | array< \ ORM \ Dbal \ Column[]> Already fetched column descriptions
protected static $emMapping ** \ ORM \ EntityManager[string] | \ ORM \ EntityManager[string][string]** Mapping for EntityManager instances
protected $map array< \ ORM \ Entity[]> The Entity map
protected $namer ** \ ORM \ Namer** The Namer instance
protected $observers array< \ ORM \ ObserverInterface[]>  
protected $options array The options set for this instance
protected static $resolver callable  
protected $resultRepository    

Methods

ORM\Testing\EntityManagerMock::__construct

public function __construct( array $options = array() )
Constructor

Visibility: this method is public.

Parameters
Parameter Type Description
$options array Options for the new EntityManager

ORM\Testing\EntityManagerMock::addEntity

public function addEntity( ORM\Entity $entity )
Add an entity to be fetched by primary key

The entity needs to have a primary key if not it will be filled with random values between RANDOM_KEY_MIN and RANDOM_KEY_MAX (at the time writing this it is 1000000000 and 1000999999).

You can pass mocks from Entity too but we need to call Entity::getPrimaryKey().

Visibility: this method is public.

Parameters
Parameter Type Description
$entity \ORM\Entity  

ORM\Testing\EntityManagerMock::addResult

public function addResult(
    $class, ORM\Entity $entities
): ORM\Testing\EntityFetcherMock\Result|Mockery\MockInterface
Create and add a EntityFetcherMock\Result for $class

As the results are mocked to come from the database they will also get a primary key if they don’t have already.

Visibility: this method is public.
Returns: this method returns \ORM\Testing\EntityFetcherMock\Result|\Mockery\MockInterface

Parameters
Parameter Type Description
$class    
$entities \ORM\Entity  

ORM\Testing\EntityManagerMock::beginTransaction

public function beginTransaction(): boolean
Begin a transaction or create a savepoint

Visibility: this method is public.
Returns: this method returns boolean

ORM\Testing\EntityManagerMock::buildChecksum

protected static function buildChecksum( array $primaryKey ): string
Build a checksum from $primaryKey

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$primaryKey array  

ORM\Testing\EntityManagerMock::buildPrimaryKey

protected static function buildPrimaryKey( $class, array $primaryKey ): array
Builds the primary key with column names as keys

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns array
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey

Parameters
Parameter Type Description
$class string | \ORM\Entity  
$primaryKey array  

ORM\Testing\EntityManagerMock::commit

public function commit( boolean $all = false ): boolean
Commit the current transaction or decrease the savepoint counter

Actually nothing will be committed if there are savepoints. Instead the counter will be decreased and the commited savepoint will still be rolled back when you call rollback afterwards.

Hopefully that gives a hint why save points are no transactions and what the limitations are.

Begin transaction
  updates / inserts for transaction1
  Create savepoint transaction1
    updates / inserts for transaction2
    Create savepoint transaction2
      updates / inserts for transaction3
    <no commit here but you called commit for transaction3>
    updates / inserts for transaction2
  rollback of transaction2 to savepoint of transaction1
  update / inserts for transaction1
commit of transaction1

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$all boolean Commit all opened transactions and savepoints

ORM\Testing\EntityManagerMock::defineForNamespace

public function defineForNamespace( $nameSpace ): $this
Define $this EntityManager as the default EntityManager for $nameSpace

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$nameSpace    

ORM\Testing\EntityManagerMock::defineForParent

public function defineForParent( $class ): $this
Define $this EntityManager as the default EntityManager for subClasses of $class

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$class    

ORM\Testing\EntityManagerMock::delete

public function delete( ORM\Entity $entity ): boolean
Delete $entity from database

This method does not delete from the map - you can still receive the entity via fetch.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entity \ORM\Entity  

ORM\Testing\EntityManagerMock::describe

public function describe(
    string $table
): array<\ORM\Dbal\Column>|ORM\Dbal\Table
Returns an array of columns from $table.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Dbal\Column>|\ORM\Dbal\Table

Parameters
Parameter Type Description
$table string  

ORM\Testing\EntityManagerMock::detach

public function detach( ORM\ObserverInterface $observer, $from = null ): boolean
Detach $observer from all classes

If the observer is attached to multiple classes all are removed except the optional parameter $from defines from which class to remove the $observer.

Returns whether or not an observer got detached.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$observer \ORM\ObserverInterface  
$from string | null  

ORM\Testing\EntityManagerMock::eagerLoad

public function eagerLoad( string $relation, ORM\Entity $entities )
Load the $relation on all $entities with the least amount of queries

$relation can be nested by dividing them with a dot.

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\UndefinedRelation

Parameters
Parameter Type Description
$relation string  
$entities \ORM\Entity  

ORM\Testing\EntityManagerMock::escapeIdentifier

public function escapeIdentifier( string $identifier ): string
Returns $identifier quoted for use in a sql statement

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$identifier string Identifier to quote

ORM\Testing\EntityManagerMock::escapeValue

public function escapeValue( $value ): string
Returns $value formatted to use in a sql statement.

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$value mixed The variable that should be returned in SQL syntax

ORM\Testing\EntityManagerMock::fetch

public function fetch(
    string $class, $primaryKey = null
): ORM\Entity|ORM\EntityFetcher
Fetch one or more entities

With $primaryKey it tries to find this primary key in the entity map (carefully: mostly the database returns a string and we do not convert them). If there is no entity in the entity map it tries to fetch the entity from the database. The return value is then null (not found) or the entity.

Without $primaryKey it creates an entityFetcher and returns this.

Visibility: this method is public.
Returns: this method returns \ORM\Entity|\ORM\EntityFetcher

Parameters
Parameter Type Description
$class string The entity class you want to fetch
$primaryKey mixed The primary key of the entity you want to fetch

ORM\Testing\EntityManagerMock::finishBulkInserts

public function finishBulkInserts( $class ): array<\ORM\Entity>
Finish the bulk insert for $class.

Returns an array of entities added.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>

Parameters
Parameter Type Description
$class    

ORM\Testing\EntityManagerMock::fire

public function fire( ORM\Event $event ): boolean
Fire $event on $entity

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$event \ORM\Event  

ORM\Testing\EntityManagerMock::getConnection

public function getConnection(): PDO
Get the pdo connection.

Visibility: this method is public.
Returns: this method returns \PDO
Throws: this method may throw \ORM\Exception\NoConnection or \ORM\Exception\NoConnection

ORM\Testing\EntityManagerMock::getDbal

public function getDbal(): ORM\Dbal\Dbal
Get the Database Abstraction Layer

Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Dbal

ORM\Testing\EntityManagerMock::getInstance

public static function getInstance( string $class = null ): ORM\EntityManager
Get an instance of the EntityManager.

If no class is given it gets $class from backtrace.

It first tries to get the EntityManager for the Namespace of $class, then for the parents of $class. If no EntityManager is found it returns the last created EntityManager (null if no EntityManager got created).

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\EntityManager

Parameters
Parameter Type Description
$class string  

ORM\Testing\EntityManagerMock::getInstanceByNameSpace

private static function getInstanceByNameSpace( $class ): ORM\EntityManager
Get the instance by NameSpace mapping

Static: this method is static.
Visibility: this method is private.
Returns: this method returns \ORM\EntityManager

Parameters
Parameter Type Description
$class    

ORM\Testing\EntityManagerMock::getInstanceByParent

private static function getInstanceByParent( $class ): ORM\EntityManager
Get the instance by Parent class mapping

Static: this method is static.
Visibility: this method is private.
Returns: this method returns \ORM\EntityManager

Parameters
Parameter Type Description
$class    

ORM\Testing\EntityManagerMock::getNamer

public function getNamer(): ORM\Namer
Get the Namer instance

Visibility: this method is public.
Returns: this method returns \ORM\Namer

ORM\Testing\EntityManagerMock::getOption

public function getOption( $option ): mixed
Get $option

Visibility: this method is public.
Returns: this method returns mixed

Parameters
Parameter Type Description
$option    

ORM\Testing\EntityManagerMock::getResults

public function getResults( string $class, ORM\EntityFetcher $fetcher ): array
Get the results for $class and $query

The EntityFetcherMock\Result gets a quality for matching this query. Only the highest quality will be used.

Visibility: this method is public.
Returns: this method returns array

Parameters
Parameter Type Description
$class string  
$fetcher \ORM\EntityFetcher  

ORM\Testing\EntityManagerMock::has

public function has( $entity, $primaryKey = null ): boolean
Check if the entity map has $entity

If you want to know if the entity already exists in the map use this method.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entity \ORM\Entity | string  
$primaryKey mixed  

ORM\Testing\EntityManagerMock::map

public function map(
    ORM\Entity $entity, boolean $update = false, string $class = null
): ORM\Entity
Map $entity in the entity map

Returns the given entity or an entity that previously got mapped. This is useful to work in every function with the same object.

$user = $enitityManager->map(new User(['id' => 42]));

Visibility: this method is public.
Returns: this method returns \ORM\Entity

Parameters
Parameter Type Description
$entity \ORM\Entity  
$update boolean Update the entity map
$class string Overwrite the class

ORM\Testing\EntityManagerMock::observe

public function observe(
    string $class, $observer = null
): ORM\Observer\CallbackObserver|null
Observe $class using $observer

If AbstractObserver is omitted it returns a new CallbackObserver. Usage example:

$em->observe(User::class)
    ->on('inserted', function (User $user) { ... })
    ->on('deleted', function (User $user) { ... });

For more information about model events please consult the [documentation](https://tflori.github.io/

Visibility: this method is public.
Returns: this method returns \ORM\Observer\CallbackObserver|null
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$class string  
$observer \ORM\ObserverInterface | null  

ORM\Testing\EntityManagerMock::query

public function query(
    string $table, string $alias = ''
): ORM\QueryBuilder\QueryBuilder
Get a query builder for $table

Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilder

Parameters
Parameter Type Description
$table string  
$alias string  

ORM\Testing\EntityManagerMock::raw

public static function raw( string $expression ): ORM\Dbal\Expression
Create a raw expression from $expression to disable escaping

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Expression

Parameters
Parameter Type Description
$expression string  

ORM\Testing\EntityManagerMock::retrieve

public function retrieve( string $class, array $primaryKey ): ORM\Entity|null
Retrieve an entity by $primaryKey

Visibility: this method is public.
Returns: this method returns \ORM\Entity|null

Parameters
Parameter Type Description
$class string  
$primaryKey array  

ORM\Testing\EntityManagerMock::rollback

public function rollback(): boolean
Rollback the current transaction or save point

Visibility: this method is public.
Returns: this method returns boolean

ORM\Testing\EntityManagerMock::setConnection

public function setConnection( $connection )
Add connection after instantiation

The connection can be an array of parameters for DbConfig::__construct(), a callable function that returns a PDO instance, an instance of DbConfig or a PDO instance itself.

When it is not a PDO instance the connection get established on first use.

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$connection mixed A configuration for (or a) PDO instance

ORM\Testing\EntityManagerMock::setOption

public function setOption( string $option, $value ): $this
Set $option to $value

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$option string One of OPT_* constants
$value mixed  

ORM\Testing\EntityManagerMock::setResolver

public static function setResolver( callable $resolver )
Overwrite the functionality of ::getInstance($class) by $resolver($class)

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$resolver callable  

ORM\Testing\EntityManagerMock::sync

public function sync( ORM\Entity $entity, boolean $reset = false ): boolean
Synchronizing $entity with database

If $reset is true it also calls reset() on $entity.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entity \ORM\Entity  
$reset boolean Reset entities current data

ORM\Testing\EntityManagerMock::useBulkInserts

public function useBulkInserts(
    string $class, integer $limit = 20
): ORM\BulkInsert
Force $class to use bulk insert.

At the end you should call finish bulk insert otherwise you may loose data.

Visibility: this method is public.
Returns: this method returns \ORM\BulkInsert

Parameters
Parameter Type Description
$class string  
$limit integer Maximum number of rows per insert

ORM\Dbal\Type\Enum

Extends: ORM\Dbal\Type

Enum data type

Properties

Visibility Name Type Description
protected $allowedValues array<string>  

Methods

ORM\Dbal\Type\Enum::__construct

public function __construct( array<string> $allowedValues )
Set constructor

Visibility: this method is public.

Parameters
Parameter Type Description
$allowedValues array<string>  

ORM\Dbal\Type\Enum::factory

public static function factory(
    ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
Returns a new Type object

This method is only for types covered by mapping. Use fromDefinition instead for custom types.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns static

Parameters
Parameter Type Description
$dbal \ORM\Dbal\Dbal  
$columnDefinition array  

ORM\Dbal\Type\Enum::fits

public static function fits( array $columnDefinition ): boolean
Check if this type fits to $columnDefinition

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$columnDefinition array  

ORM\Dbal\Type\Enum::getAllowedValues

public function getAllowedValues(): array<string>

Visibility: this method is public.
Returns: this method returns array<mixed,string>

ORM\Dbal\Type\Enum::validate

public function validate( $value ): boolean|ORM\Dbal\Error
Check if $value is valid for this type

Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error

Parameters
Parameter Type Description
$value mixed  

ORM\Dbal\Error

Extends: ORM\Exception

Validation Error

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.

Constants

Name Value
ERROR_CODE 'UNKNOWN'

Properties

Visibility Name Type Description
protected $errorCode string  
protected $message string  

Methods

ORM\Dbal\Error::__construct

public function __construct(
    array $params = array(), null $code = null, null $message = null, 
    ORM\Dbal\Error $previous = null
)
Error constructor

Visibility: this method is public.

Parameters
Parameter Type Description
$params array  
$code null  
$message null  
$previous Error  

ORM\Event

Constants

Name Value
NAME 'event'

Properties

Visibility Name Type Description
protected $data array  
protected $entity Entity  
protected $stopped boolean  

Methods

ORM\Event::__construct

public function __construct( ORM\Entity $entity )

Visibility: this method is public.

Parameters
Parameter Type Description
$entity Entity  

ORM\Event::__get

public function __get( $name )

Visibility: this method is public.

Parameters
Parameter Type Description
$name    

ORM\Event::stop

public function stop()

Visibility: this method is public.


ORM\Exception

Extends:

Base exception for ORM

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Dbal\Expression

Properties

Visibility Name Type Description
protected $expression    

Methods

ORM\Dbal\Expression::__construct

public function __construct( string $expression )
Expression constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$expression string  

ORM\Dbal\Expression::__toString

public function __toString()

Visibility: this method is public.


ORM\Event\Fetched

Extends: ORM\Event

Constants

Name Value
NAME 'fetched'

Properties

Visibility Name Type Description
protected $data array  
protected $entity ** \ ORM \ Entity**  
protected $rawData array  
protected $stopped boolean  

Methods

ORM\Event\Fetched::__construct

public function __construct( ORM\Entity $entity, array $rawData )

Visibility: this method is public.

Parameters
Parameter Type Description
$entity \ORM\Entity  
$rawData array  

ORM\Event\Fetched::__get

public function __get( $name )

Visibility: this method is public.

Parameters
Parameter Type Description
$name    

ORM\Event\Fetched::stop

public function stop()

Visibility: this method is public.


ORM\EntityFetcher\FilterInterface

Methods

ORM\EntityFetcher\FilterInterface::apply

public function apply( ORM\EntityFetcher $fetcher ): void
Apply this filter to $fetcher

Visibility: this method is public.
Returns: this method returns void

Parameters
Parameter Type Description
$fetcher \ORM\EntityFetcher  

ORM\Entity\GeneratesPrimaryKeys

Interface GeneratesPrimaryKeys

Describes a class that generates primary keys in the protected method generatePrimaryKey()


ORM\Helper

Methods

ORM\Helper::first

public static function first( array $array, $default = null ): mixed
Get the first element of $array

Returns $default if the array is empty.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns mixed

Parameters
Parameter Type Description
$array array  
$default mixed  

ORM\Helper::getData

private static function getData( $item, $key )

Static: this method is static.
Visibility: this method is private.

Parameters
Parameter Type Description
$item    
$key    

ORM\Helper::getKey

public static function getKey(
    array $reference, ORM\Entity $entity, boolean $allowEmpty = true
): array|null
Get the key (defined by $referenced) from $entity

Reference defines the mapping of attributes in $entity to attributes in the referenced object.

Example: $entity is an Article and the ‘userId’ references the ‘id’ of the user. Then $reference should be ['userId' => 'id'] and the result will be ['id' => 23]

Static: this method is static.
Visibility: this method is public.
Returns: this method returns array|null
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey

Parameters
Parameter Type Description
$reference array  
$entity Entity  
$allowEmpty boolean  

ORM\Helper::getUniqueKeys

public static function getUniqueKeys(
    array $reference, ORM\Entity $entities
): array|false
Get a unique list of keys (defined by $reference) from $entities

Static: this method is static.
Visibility: this method is public.
Returns: this method returns array|false

Parameters
Parameter Type Description
$reference array  
$entities Entity  

See Also:

private static function getValueRetriever( $retriever )

Static: this method is static.
Visibility: this method is private.

Parameters
Parameter Type Description
$retriever    

ORM\Helper::groupBy

public static function groupBy( array $array, $retriever )

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$array array  
$retriever    

ORM\Helper::keyBy

public static function keyBy( array $array, $retriever ): array|false
Create an associative array where the key

Static: this method is static.
Visibility: this method is public.
Returns: this method returns array|false

Parameters
Parameter Type Description
$array array  
$retriever    

ORM\Helper::only

public static function only( array $array, array $keys )

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$array array  
$keys array  

ORM\Helper::pluck

public static function pluck( array $array, $retriever )

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$array array  
$retriever    

ORM\Helper::shortName

public static function shortName( string $class ): string
Gets the short name of a class without creating a Reflection

Static: this method is static.
Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$class string  

ORM\Helper::traitUsesRecursive

public static function traitUsesRecursive(
    string $class, boolean $withParents = true
): array<string>
Get all traits used by the class and it’s parents.

Iterates recursively through traits to get traits used by traits.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns array<mixed,string>

Parameters
Parameter Type Description
$class string  
$withParents boolean  

ORM\Helper::uniqueArrays

public static function uniqueArrays( array<array> $array ): array
Make an array of arrays unique

Static: this method is static.
Visibility: this method is public.
Returns: this method returns array

Parameters
Parameter Type Description
$array array<array>  

ORM\Exception\IncompletePrimaryKey

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Event\Inserted

Extends: ORM\Event

Constants

Name Value
NAME 'inserted'

Properties

Visibility Name Type Description
protected $data array  
protected $entity ** \ ORM \ Entity**  
protected $stopped boolean  

ORM\Event\Inserting

Extends: ORM\Event

Constants

Name Value
NAME 'inserting'

Properties

Visibility Name Type Description
protected $data array  
protected $entity ** \ ORM \ Entity**  
protected $stopped boolean  

ORM\Exception\InvalidArgument

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Exception\InvalidConfiguration

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Dbal\Error\InvalidJson

Extends: ORM\Dbal\Error

InvalidJson Validation Error

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.

Constants

Name Value
ERROR_CODE 'INVALID_JSON'

Properties

Visibility Name Type Description
protected $errorCode string  
protected $message string  

ORM\Exception\InvalidName

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Exception\InvalidRelation

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Exception\InvalidType

Extends: ORM\Exception

Base exception for ORM

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Dbal\Type\Json

Extends: ORM\Dbal\Type

Json data type

Methods

ORM\Dbal\Type\Json::factory

public static function factory(
    ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
Returns a new Type object

This method is only for types covered by mapping. Use fromDefinition instead for custom types.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns static

Parameters
Parameter Type Description
$dbal \ORM\Dbal\Dbal  
$columnDefinition array  

ORM\Dbal\Type\Json::fits

public static function fits( array $columnDefinition ): boolean
Check if this type fits to $columnDefinition

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$columnDefinition array  

ORM\Dbal\Type\Json::validate

public function validate( $value ): boolean|ORM\Dbal\Error
Check if $value is valid for this type

Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error

Parameters
Parameter Type Description
$value mixed  

ORM\Relation\ManyToMany

Extends: ORM\Relation

ManyToMany Relation

Properties

Visibility Name Type Description
protected $class string The class that is related
protected $filters array Filters applied to all fetchers
protected $name string The name of the relation for error messages
protected $opponent string The name of the relation in the related class
protected $parent string The parent entity that defined this relation
protected $reference array Reference definition as key value pairs
protected $table string The table that holds the foreign keys

Methods

ORM\Relation\ManyToMany::__construct

public function __construct(
    string $class, array $reference, string $opponent, string $table, 
    $filters = array()
)
ManyToMany constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$class string  
$reference array  
$opponent string  
$table string  
$filters array<\ORM\EntityFetcher\FilterInterface> | array<callable>  

ORM\Relation\ManyToMany::addJoin

public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
{@inheritdoc}

Visibility: this method is public.

Parameters
Parameter Type Description
$fetcher \ORM\EntityFetcher  
$join    
$alias    

ORM\Relation\ManyToMany::addRelated

public function addRelated(
    ORM\Entity $self, array $entities, ORM\EntityManager $entityManager
)
Add $entities to association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey or \ORM\Exception\InvalidRelation or \ORM\Exception\IncompletePrimaryKey

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array  
$entityManager \ORM\EntityManager  

ORM\Relation\ManyToMany::assignForeignObjects

protected function assignForeignObjects(
    array $fkAttributes, array $keyAttributes, array $entities, 
    array $foreignObjects
)
Assign $foreignObjects to $entities mapped by attributes

Visibility: this method is protected.

Parameters
Parameter Type Description
$fkAttributes array  
$keyAttributes array  
$entities array  
$foreignObjects array  

ORM\Relation\ManyToMany::checkBoundTo

protected function checkBoundTo( $parent, $name )
Check if the relation is bound to $parent and throw if not

Visibility: this method is protected.
Throws: this method may throw \ORM\Exception

Parameters
Parameter Type Description
$parent    
$name    

ORM\Relation\ManyToMany::createFetcher

protected function createFetcher(
    ORM\EntityManager $entityManager
): ORM\EntityFetcher

Visibility: this method is protected.
Returns: this method returns \ORM\EntityFetcher

Parameters
Parameter Type Description
$entityManager \ORM\EntityManager  

ORM\Relation\ManyToMany::createRelation

public static function createRelation(
    string $parent, string $name, array $relDef
): ORM\Relation
Factory for relation definition object

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$parent string  
$name string  
$relDef array  

ORM\Relation\ManyToMany::deleteRelated

public function deleteRelated(
    ORM\Entity $self, array $entities, ORM\EntityManager $entityManager
)
Delete $entities from association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey or \ORM\Exception\InvalidRelation or \ORM\Exception\IncompletePrimaryKey

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array  
$entityManager \ORM\EntityManager  

ORM\Relation\ManyToMany::eagerLoad

public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Load this relation for all $entities with one query

Visibility: this method is public.

Parameters
Parameter Type Description
$em \ORM\EntityManager  
$entities \ORM\Entity  

ORM\Relation\ManyToMany::fetch

public function fetch(
    ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Fetch the relation

Runs fetch on the EntityManager and returns its result.

Visibility: this method is public.
Returns: this method returns mixed

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\ManyToMany::fetchAll

public function fetchAll(
    ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
Fetch all from the relation

Runs fetch and returns EntityFetcher::all() if a Fetcher is returned.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>|\ORM\Entity

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\ManyToMany::fromAssoc

protected static function fromAssoc( $parent, array $relDef )
{@inheritDoc}

Static: this method is static.
Visibility: this method is protected.

Parameters
Parameter Type Description
$parent    
$relDef array  

ORM\Relation\ManyToMany::fromShort

public static function fromShort( $parent, array $short )
{@inheritDoc}

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$parent    
$short array  

ORM\Relation\ManyToMany::getMappingData

protected function getMappingData(
    ORM\EntityManager $em, array<\ORM\Entity> $entities
): array

Visibility: this method is protected.
Returns: this method returns array

Parameters
Parameter Type Description
$em \ORM\EntityManager  
$entities array<\ORM\Entity>  

ORM\Relation\ManyToMany::getOpponent

protected function getOpponent(
    string $requiredType = null
): ORM\Relation\Owner|ORM\Relation\ManyToMany

Visibility: this method is protected.
Returns: this method returns \ORM\Relation\Owner|\ORM\Relation\ManyToMany
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$requiredType string  

ORM\Relation\ManyToMany::getReference

public function getReference()

Visibility: this method is public.

ORM\Relation\ManyToMany::getTable

public function getTable(): string

Visibility: this method is public.
Returns: this method returns string

ORM\Relation\ManyToMany::setRelated

public function setRelated( ORM\Entity $self, $entity = null )
Set the relation to $entity

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entity \ORM\Entity | null  

ORM\Relation\Morphed

Extends: ORM\Relation\Owner

Owner Relation

Properties

Visibility Name Type Description
protected $class string The class that is related
protected $filters array Filters applied to all fetchers
protected $morphColumn string Column where the type gets persisted
protected $morphMap array Array of value => class pairs
protected $morphReference array Reference definition
protected $name string The name of the relation for error messages
protected $parent string The parent entity that defined this relation
protected $reference array Reference definition as key value pairs
protected $super string The parent class that all morphed elements have to extend

Methods

ORM\Relation\Morphed::__construct

public function __construct( string $morphColumn, $morph, array $reference )
Morphed constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$morphColumn string  
$morph string | array  
$reference array  

ORM\Relation\Morphed::addJoin

public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
{@inheritdoc}

Visibility: this method is public.

Parameters
Parameter Type Description
$fetcher \ORM\EntityFetcher  
$join    
$alias    

ORM\Relation\Morphed::addRelated

public function addRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Add $entities to association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array<\ORM\Entity>  
$entityManager \ORM\EntityManager  

ORM\Relation\Morphed::apply

public function apply( ORM\EntityFetcher $fetcher, ORM\Entity $entity )
Apply where conditions for $entity on $fetcher

Called from non-owner to find related elements. Example: $user->fetch(‘articles’) creates an EntityFetcher for Article and calls $opponent->apply($fetcher, $user) that will call $fetcher->where(‘authorId’, $user->id)

Visibility: this method is public.

Parameters
Parameter Type Description
$fetcher \ORM\EntityFetcher  
$entity \ORM\Entity  

ORM\Relation\Morphed::applyJoin

public function applyJoin(
    ORM\QueryBuilder\Parenthesis $join, string $yourAlias, 
    ORM\Relation\OneToMany $opponent
)
Adds the join clause to the entity fetcher

Visibility: this method is public.

Parameters
Parameter Type Description
$join \ORM\QueryBuilder\Parenthesis  
$yourAlias string  
$opponent OneToMany  

ORM\Relation\Morphed::assignForeignObjects

protected function assignForeignObjects(
    array $fkAttributes, array $keyAttributes, array $entities, 
    array $foreignObjects
)
Assign $foreignObjects to $entities mapped by attributes

Visibility: this method is protected.

Parameters
Parameter Type Description
$fkAttributes array  
$keyAttributes array  
$entities array  
$foreignObjects array  

ORM\Relation\Morphed::checkBoundTo

protected function checkBoundTo( $parent, $name )
Check if the relation is bound to $parent and throw if not

Visibility: this method is protected.
Throws: this method may throw \ORM\Exception

Parameters
Parameter Type Description
$parent    
$name    

ORM\Relation\Morphed::cleanReferences

protected function cleanReferences( ORM\Entity $self, string $newType = null )

When we define different columns per type for the id we have to clean up every column that is currently unused to prevent cascaded removals.

Visibility: this method is protected.

Parameters
Parameter Type Description
$self \ORM\Entity  
$newType string  

ORM\Relation\Morphed::createRelation

public static function createRelation(
    string $parent, string $name, array $relDef
): ORM\Relation
Factory for relation definition object

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$parent string  
$name string  
$relDef array  

ORM\Relation\Morphed::deleteRelated

public function deleteRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Delete $entities from association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array<\ORM\Entity>  
$entityManager \ORM\EntityManager  

ORM\Relation\Morphed::eagerLoad

public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Load all foreign objects of all $entities with one query

Visibility: this method is public.

Parameters
Parameter Type Description
$em \ORM\EntityManager  
$entities \ORM\Entity  

ORM\Relation\Morphed::eagerLoadSelf

public function eagerLoadSelf(
    ORM\EntityManager $em, ORM\Entity $foreignObjects
)

Visibility: this method is public.

Parameters
Parameter Type Description
$em \ORM\EntityManager  
$foreignObjects \ORM\Entity  

ORM\Relation\Morphed::fetch

public function fetch(
    ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Fetch the relation

Runs fetch on the EntityManager and returns its result.

Visibility: this method is public.
Returns: this method returns mixed

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\Morphed::fetchAll

public function fetchAll(
    ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
Fetch all from the relation

Runs fetch and returns EntityFetcher::all() if a Fetcher is returned.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>|\ORM\Entity

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\Morphed::fromAssoc

public static function fromAssoc( $parent, array $relDef )
{@inheritDoc}

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$parent    
$relDef array  

ORM\Relation\Morphed::fromShort

public static function fromShort( $parent, array $short )
{@inheritDoc}

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$parent    
$short array  

ORM\Relation\Morphed::getMorphedClass

protected function getMorphedClass( string $type ): string
Get the class for $type

Visibility: this method is protected.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\InvalidType

Parameters
Parameter Type Description
$type string  

ORM\Relation\Morphed::getMorphedReference

protected function getMorphedReference( string $type ): array
Get the reference for $type

Visibility: this method is protected.
Returns: this method returns array

Parameters
Parameter Type Description
$type string  

ORM\Relation\Morphed::getReference

public function getReference()

Visibility: this method is public.

ORM\Relation\Morphed::getType

protected function getType( $class ): integer|string
Get the type of an entity

Because of morph maps the type could be something different than the class name.

If the type is not a subclass of $this->super or the it throws.

Visibility: this method is protected.
Returns: this method returns integer|string
Throws: this method may throw \ORM\Exception\InvalidType

Parameters
Parameter Type Description
$class \ORM\Entity | string  

ORM\Relation\Morphed::hasForeignKeysByType

protected function hasForeignKeysByType(): boolean
Check if the foreign keys differ by type

Visibility: this method is protected.
Returns: this method returns boolean

ORM\Relation\Morphed::setRelated

public function setRelated( ORM\Entity $self, ORM\Entity $entity = null )
Set the relation to $entity

Visibility: this method is public.

Parameters
Parameter Type Description
$self \ORM\Entity  
$entity \ORM\Entity  

ORM\Dbal\Mysql

Extends: ORM\Dbal\Dbal

Database abstraction for MySQL databases

Properties

Visibility Name Type Description
protected $booleanFalse string  
protected $booleanTrue string  
protected $entityManager ** \ ORM \ EntityManager**  
protected $identifierDivider string  
protected $quotingCharacter string  
protected $transactionCounter integer Number of opened transactions
protected static $typeMapping array  

Methods

ORM\Dbal\Mysql::__construct

public function __construct(
    ORM\EntityManager $entityManager, array $options = array()
)
Dbal constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$entityManager \ORM\EntityManager  
$options array  

ORM\Dbal\Mysql::assertSameType

protected static function assertSameType(
    array<\ORM\Entity> $entities
): boolean

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns boolean
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$entities array<\ORM\Entity>  

ORM\Dbal\Mysql::beginTransaction

public function beginTransaction(): boolean
Begin a transaction or create a savepoint

Visibility: this method is public.
Returns: this method returns boolean

ORM\Dbal\Mysql::buildCompositeInExpression

public function buildCompositeInExpression(
    array $cols, array $values, boolean $inverse = false
): string
Build a where in expression for composite values

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$cols array  
$values array  
$inverse boolean Whether it should be a IN or NOT IN operator

ORM\Dbal\Mysql::buildDeleteStatement

protected function buildDeleteStatement( $table, array $where )

Visibility: this method is protected.

Parameters
Parameter Type Description
$table    
$where array  

ORM\Dbal\Mysql::buildInsert

protected function buildInsert( string $table, array $rows ): string
Build an insert statement for $rows

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$table string  
$rows array  

ORM\Dbal\Mysql::buildSetClause

protected function buildSetClause( array $updates )

Visibility: this method is protected.

Parameters
Parameter Type Description
$updates array  

ORM\Dbal\Mysql::buildTuples

protected function buildTuples( array $values )

Visibility: this method is protected.

Parameters
Parameter Type Description
$values array  

ORM\Dbal\Mysql::buildUpdateJoinStatement

protected function buildUpdateJoinStatement(
    $table, array $where, array $updates, array $joins
)

Visibility: this method is protected.

Parameters
Parameter Type Description
$table    
$where array  
$updates array  
$joins array  

ORM\Dbal\Mysql::buildUpdateStatement

protected function buildUpdateStatement( $table, array $where, array $updates )

Visibility: this method is protected.

Parameters
Parameter Type Description
$table    
$where array  
$updates array  

ORM\Dbal\Mysql::commit

public function commit( boolean $all = false ): boolean
Commit the current transaction or decrease the savepoint counter

Actually nothing will be committed if there are savepoints. Instead the counter will be decreased and the commited savepoint will still be rolled back when you call rollback afterwards.

Hopefully that gives a hint why save points are no transactions and what the limitations are.

Begin transaction
  updates / inserts for transaction1
  Create savepoint transaction1
    updates / inserts for transaction2
    Create savepoint transaction2
      updates / inserts for transaction3
    <no commit here but you called commit for transaction3>
    updates / inserts for transaction2
  rollback of transaction2 to savepoint of transaction1
  update / inserts for transaction1
commit of transaction1

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$all boolean Commit all opened transactions and savepoints

ORM\Dbal\Mysql::delete

public function delete( string $table, array $where ): integer
Delete rows from $table using $where conditions

Where conditions can be an array of key => value pairs to check for equality or an array of expressions.

Examples: $dbal->delete('someTable', ['id' => 23]) $dbal->delete('user', ['name = \'john\'', 'OR email=\'john.doe@example.com\''])

Tip: Use the query builder to construct where conditions: $em->query('user')->where('name', 'john')->orWhere('email', '...')->delete();

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows

Parameters
Parameter Type Description
$table string The table where to delete rows
$where array An array of where conditions

ORM\Dbal\Mysql::deleteEntity

public function deleteEntity( ORM\Entity $entity ): boolean
Delete $entity from database

This method does not delete from the map - you can still receive the entity via fetch.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entity \ORM\Entity  

ORM\Dbal\Mysql::describe

public function describe(
    string $table
): ORM\Dbal\Table|array<\ORM\Dbal\Column>
Describe a table

Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Table|array<mixed,\ORM\Dbal\Column>

Parameters
Parameter Type Description
$table string  

ORM\Dbal\Mysql::escapeBoolean

protected function escapeBoolean( boolean $value ): string
Escape a boolean for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value boolean  

ORM\Dbal\Mysql::escapeDateTime

protected function escapeDateTime( DateTime $value ): mixed
Escape a date time object for query

Visibility: this method is protected.
Returns: this method returns mixed

Parameters
Parameter Type Description
$value \DateTime  

ORM\Dbal\Mysql::escapeDouble

protected function escapeDouble( double $value ): string
Escape a double for Query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value double  

ORM\Dbal\Mysql::escapeIdentifier

public function escapeIdentifier( string $identifier ): string
Returns $identifier quoted for use in a sql statement

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$identifier string Identifier to quote

ORM\Dbal\Mysql::escapeInteger

protected function escapeInteger( integer $value ): string
Escape an integer for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value integer  

ORM\Dbal\Mysql::escapeNULL

protected function escapeNULL(): string
Escape NULL for query

Visibility: this method is protected.
Returns: this method returns string

ORM\Dbal\Mysql::escapeString

protected function escapeString( string $value ): string
Escape a string for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value string  

ORM\Dbal\Mysql::escapeValue

public function escapeValue( $value ): string
Returns $value formatted to use in a sql statement.

Visibility: this method is public.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotScalar

Parameters
Parameter Type Description
$value mixed The variable that should be returned in SQL syntax

ORM\Dbal\Mysql::extractParenthesis

protected function extractParenthesis( string $type ): string
Extract content from parenthesis in $type

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$type string  

ORM\Dbal\Mysql::insert

public function insert( $table, array $rows )

Visibility: this method is public.

Parameters
Parameter Type Description
$table    
$rows array  

ORM\Dbal\Mysql::insertAndSync

public function insertAndSync( ORM\Entity $entities ): boolean
Insert $entities and update with default values from database

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns boolean
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Mysql::insertAndSyncWithAutoInc

public function insertAndSyncWithAutoInc(
    ORM\Entity $entities
): integer|boolean
Insert $entities and sync with auto increment primary key

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns integer|boolean

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Mysql::insertEntities

public function insertEntities( ORM\Entity $entities ): boolean
Insert $entities into database

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Mysql::normalizeColumnDefinition

protected function normalizeColumnDefinition( array $rawColumn ): array
Normalize a column definition

The column definition from “DESCRIBE <table>” is to special as useful. Here we normalize it to a more ANSI-SQL style.

Visibility: this method is protected.
Returns: this method returns array

Parameters
Parameter Type Description
$rawColumn array  

ORM\Dbal\Mysql::normalizeType

protected function normalizeType( string $type ): string
Normalize $type

The type returned by mysql is for example VARCHAR(20) - this function converts it to varchar

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$type string  

ORM\Dbal\Mysql::rollback

public function rollback(): boolean
Rollback the current transaction or save point

Visibility: this method is public.
Returns: this method returns boolean

ORM\Dbal\Mysql::setOption

public function setOption( string $option, $value ): $this
Set $option to $value

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$option string  
$value mixed  

ORM\Dbal\Mysql::syncInserted

protected function syncInserted( ORM\Entity $entities )
Sync the $entities after insert

Visibility: this method is protected.

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Mysql::syncInsertedWithAutoInc

protected function syncInsertedWithAutoInc( ORM\Entity $entities )
Synchronize inserted $entities

This method expects that the inserted $entities where the last inserted entities and using an auto incremented primary key.

Visibility: this method is protected.

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Mysql::update

public function update(
    string $table, array $where, array $updates, array $joins = array()
): integer
Update $table using $where to set $updates

Simple usage: update('table', ['id' => 23], ['name' => 'John Doe'])

For advanced queries with parenthesis, joins (if supported from your DBMS) etc. use QueryBuilder:

$em->query('table')
 ->where('birth_date', '>', EM::raw('DATE_SUB(NOW(), INTERVAL 18 YEARS)'))
 ->update(['teenager' => true]);

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of affected rows

Parameters
Parameter Type Description
$table string The table to update
$where array An array of where conditions
$updates array An array of columns to update
$joins array For internal use from query builder only

ORM\Dbal\Mysql::updateAutoincrement

protected function updateAutoincrement( ORM\Entity $entity, $value )
Update the autoincrement value

Visibility: this method is protected.

Parameters
Parameter Type Description
$entity \ORM\Entity  
$value integer | string  

ORM\Namer

Namer is for naming errors, columns, tables and methods

Namer is an artificial word and is more a name giver. We just don’t wanted to write so much.

Properties

Visibility Name Type Description
protected $attributeNameScheme string The naming scheme used for attributes.
protected $columnNameScheme string The naming scheme to use for column names.
protected $columnNames array<string[]>  
protected $methodNameScheme string The naming scheme used for method names.
protected $tableNameScheme string The naming scheme to use for table names.
protected $tableNameTemplate string The template to use to calculate the table name.
protected $tableNames array<string>  

Methods

ORM\Namer::__construct

public function __construct( array $options = array() )
Namer constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$options array  

ORM\Namer::arrayToString

protected function arrayToString(
    array $array, string $accessor, string $glue
): string
Convert array to string using indexes defined by $accessor

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$array array  
$accessor string  
$glue string  

ORM\Namer::forceNamingScheme

public function forceNamingScheme( string $name, string $namingScheme ): string
Enforce $namingScheme to $name

Supported naming schemes: snake_case, snake_lower, SNAKE_UPPER, Snake_Ucfirst, camelCase, StudlyCaps, lower and UPPER.

Visibility: this method is public.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$name string The name of the var / column
$namingScheme string The naming scheme to use

ORM\Namer::getAttributeName

public function getAttributeName(
    string $name, $prefix = null, string $namingScheme = null
): string
Get the attribute name with $namingScheme or default naming scheme

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$name string  
$prefix    
$namingScheme string  

ORM\Namer::getColumnName

public function getColumnName(
    string $class, string $attribute, string $prefix = null, 
    string $namingScheme = null
): string
Get the column name with $namingScheme or default naming scheme

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$class string  
$attribute string  
$prefix string  
$namingScheme string  

ORM\Namer::getMethodName

public function getMethodName(
    string $name, string $namingScheme = null
): string
Get the method name with $namingScheme or default naming scheme

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$name string  
$namingScheme string  

ORM\Namer::getTableName

public function getTableName(
    string $class, string $template = null, string $namingScheme = null
): string
Get the table name for $reflection

Visibility: this method is public.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\InvalidName

Parameters
Parameter Type Description
$class string  
$template string  
$namingScheme string  

ORM\Namer::getValue

protected function getValue(
    string $attribute, array $values, string $arrayGlue
): string
Get the value for $attribute from $values using $arrayGlue

Visibility: this method is protected.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$attribute string The key for $values
$values array  
$arrayGlue string  

ORM\Namer::setOption

public function setOption( string $option, $value ): $this
Set $option to $value

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$option string  
$value mixed  

ORM\Namer::substitute

public function substitute(
    string $template, array $values = array(), string $arrayGlue = ', '
): string
Substitute a $template with $values

$values is a key value pair array. The value should be a string or an array o

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$template string  
$values array  
$arrayGlue string  

ORM\Dbal\Error\NoBoolean

Extends: ORM\Dbal\Error

NoBoolean Validation Error

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.

Constants

Name Value
ERROR_CODE 'NO_BOOLEAN'

Properties

Visibility Name Type Description
protected $errorCode string  
protected $message string  

ORM\Exception\NoConnection

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Dbal\Error\NoDateTime

Extends: ORM\Dbal\Error

NoDateTime Validation Error

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.

Constants

Name Value
ERROR_CODE 'NO_DATETIME'

Properties

Visibility Name Type Description
protected $errorCode string  
protected $message string  

ORM\Exception\NoEntity

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Exception\NoEntityManager

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Dbal\Error\NoNumber

Extends: ORM\Dbal\Error

NoNumber Validation Error

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.

Constants

Name Value
ERROR_CODE 'NO_NUMBER'

Properties

Visibility Name Type Description
protected $errorCode string  
protected $message string  

ORM\Exception\NoOperator

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Dbal\Error\NoString

Extends: ORM\Dbal\Error

NoString Validation Error

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.

Constants

Name Value
ERROR_CODE 'NO_STRING'

Properties

Visibility Name Type Description
protected $errorCode string  
protected $message string  

ORM\Dbal\Error\NotAllowed

Extends: ORM\Dbal\Error

NotAllowed Validation Error

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.

Constants

Name Value
ERROR_CODE 'NOT_ALLOWED'

Properties

Visibility Name Type Description
protected $errorCode string  
protected $message string  

ORM\Dbal\Error\NoTime

Extends: ORM\Dbal\Error

NoTime Validation Error

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.

Constants

Name Value
ERROR_CODE 'NO_TIME'

Properties

Visibility Name Type Description
protected $errorCode string  
protected $message string  

ORM\Exception\NotJoined

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Dbal\Error\NotNullable

Extends: ORM\Dbal\Error

NotNullable Validation Error

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.

Constants

Name Value
ERROR_CODE 'NOT_NULLABLE'

Properties

Visibility Name Type Description
protected $errorCode string  
protected $message string  

Methods

ORM\Dbal\Error\NotNullable::__construct

public function __construct( ORM\Dbal\Column $column )
Error constructor

Visibility: this method is public.

Parameters
Parameter Type Description
$column \ORM\Dbal\Column  

ORM\Exception\NotScalar

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Dbal\Error\NotValid

Extends: ORM\Dbal\Error

NotValid Validation Error

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.

Constants

Name Value
ERROR_CODE 'NOT_VALID'

Properties

Visibility Name Type Description
protected $errorCode string  
protected $message string  

Methods

ORM\Dbal\Error\NotValid::__construct

public function __construct( ORM\Dbal\Column $column, ORM\Dbal\Error $previous )
NotValid constructor

Visibility: this method is public.

Parameters
Parameter Type Description
$column \ORM\Dbal\Column The column that got a not valid error
$previous \ORM\Dbal\Error The error from validate

ORM\Dbal\Type\Number

Extends: ORM\Dbal\Type

Float, double and decimal data type

Methods

ORM\Dbal\Type\Number::factory

public static function factory(
    ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
Returns a new Type object

This method is only for types covered by mapping. Use fromDefinition instead for custom types.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns static

Parameters
Parameter Type Description
$dbal \ORM\Dbal\Dbal  
$columnDefinition array  

ORM\Dbal\Type\Number::fits

public static function fits( array $columnDefinition ): boolean
Check if this type fits to $columnDefinition

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$columnDefinition array  

ORM\Dbal\Type\Number::validate

public function validate( $value ): boolean|ORM\Dbal\Error
Check if $value is valid for this type

Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error

Parameters
Parameter Type Description
$value mixed  

ORM\ObserverInterface

AbstractObserver for entity events

When a handler returns false it will cancel other event handlers and if applicable stops the execution (saving, inserting, updating and deleting can be canceled).

Methods

ORM\ObserverInterface::handle

public function handle( ORM\Event $event ): boolean
Handles the $event.

Return false to stop event execution.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$event Event  

ORM\Relation\OneToMany

Extends: ORM\Relation

OneToMany Relation

Properties

Visibility Name Type Description
protected $class string The class that is related
protected $filters array Filters applied to all fetchers
protected $name string The name of the relation for error messages
protected $opponent string The name of the relation in the related class
protected $parent string The parent entity that defined this relation

Methods

ORM\Relation\OneToMany::__construct

public function __construct(
    string $class, string $opponent, $filters = array()
)
Owner constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$class string  
$opponent string  
$filters array<\ORM\EntityFetcher\FilterInterface> | array<callable>  

ORM\Relation\OneToMany::addJoin

public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
{@inheritdoc}

Visibility: this method is public.

Parameters
Parameter Type Description
$fetcher \ORM\EntityFetcher  
$join    
$alias    

ORM\Relation\OneToMany::addRelated

public function addRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Add $entities to association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array<\ORM\Entity>  
$entityManager \ORM\EntityManager  

ORM\Relation\OneToMany::assignForeignObjects

protected function assignForeignObjects(
    array $fkAttributes, array $keyAttributes, array $entities, 
    array $foreignObjects
)
Assign $foreignObjects to $entities mapped by attributes

Visibility: this method is protected.

Parameters
Parameter Type Description
$fkAttributes array  
$keyAttributes array  
$entities array  
$foreignObjects array  

ORM\Relation\OneToMany::checkBoundTo

protected function checkBoundTo( $parent, $name )
Check if the relation is bound to $parent and throw if not

Visibility: this method is protected.
Throws: this method may throw \ORM\Exception

Parameters
Parameter Type Description
$parent    
$name    

ORM\Relation\OneToMany::createRelation

public static function createRelation(
    string $parent, string $name, array $relDef
): ORM\Relation
Factory for relation definition object

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$parent string  
$name string  
$relDef array  

ORM\Relation\OneToMany::createStaticFromAssoc

protected static function createStaticFromAssoc( array $relDef ): static|null
Create static::class from $relDef

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null

Parameters
Parameter Type Description
$relDef array  

ORM\Relation\OneToMany::createStaticFromShort

protected static function createStaticFromShort( array $short ): static|null
Create static::class from $short

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null

Parameters
Parameter Type Description
$short array  

ORM\Relation\OneToMany::deleteRelated

public function deleteRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Delete $entities from association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array<\ORM\Entity>  
$entityManager \ORM\EntityManager  

ORM\Relation\OneToMany::eagerLoad

public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Load this relation for all $entities with one query

Visibility: this method is public.

Parameters
Parameter Type Description
$em \ORM\EntityManager  
$entities \ORM\Entity  

ORM\Relation\OneToMany::fetch

public function fetch(
    ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Fetch the relation

Runs fetch on the EntityManager and returns its result.

Visibility: this method is public.
Returns: this method returns mixed
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\OneToMany::fetchAll

public function fetchAll(
    ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
Fetch all from the relation

Runs fetch and returns EntityFetcher::all() if a Fetcher is returned.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>|\ORM\Entity

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\OneToMany::fromAssoc

protected static function fromAssoc( $parent, array $relDef )
{@inheritDoc}

Static: this method is static.
Visibility: this method is protected.

Parameters
Parameter Type Description
$parent    
$relDef array  

ORM\Relation\OneToMany::fromShort

public static function fromShort( $parent, array $short )
{@inheritDoc}

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$parent    
$short array  

ORM\Relation\OneToMany::getOpponent

protected function getOpponent(
    string $requiredType = null
): ORM\Relation\Owner|ORM\Relation\ManyToMany

Visibility: this method is protected.
Returns: this method returns \ORM\Relation\Owner|\ORM\Relation\ManyToMany
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$requiredType string  

ORM\Relation\OneToMany::setRelated

public function setRelated( ORM\Entity $self, $entity = null )
Set the relation to $entity

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entity \ORM\Entity | null  

ORM\Relation\OneToOne

Extends: ORM\Relation\OneToMany

OneToOne Relation

Properties

Visibility Name Type Description
protected $class string The class that is related
protected $filters array Filters applied to all fetchers
protected $name string The name of the relation for error messages
protected $opponent string The name of the relation in the related class
protected $parent string The parent entity that defined this relation

Methods

ORM\Relation\OneToOne::__construct

public function __construct(
    string $class, string $opponent, $filters = array()
)
Owner constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$class string  
$opponent string  
$filters array<\ORM\EntityFetcher\FilterInterface> | array<callable>  

ORM\Relation\OneToOne::addJoin

public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
{@inheritdoc}

Visibility: this method is public.

Parameters
Parameter Type Description
$fetcher \ORM\EntityFetcher  
$join    
$alias    

ORM\Relation\OneToOne::addRelated

public function addRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Add $entities to association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array<\ORM\Entity>  
$entityManager \ORM\EntityManager  

ORM\Relation\OneToOne::assignForeignObjects

protected function assignForeignObjects(
    array $fkAttributes, array $keyAttributes, array $entities, 
    array $foreignObjects
)
Assign $foreignObjects to $entities mapped by attributes

Visibility: this method is protected.

Parameters
Parameter Type Description
$fkAttributes array  
$keyAttributes array  
$entities array  
$foreignObjects array  

ORM\Relation\OneToOne::checkBoundTo

protected function checkBoundTo( $parent, $name )
Check if the relation is bound to $parent and throw if not

Visibility: this method is protected.
Throws: this method may throw \ORM\Exception

Parameters
Parameter Type Description
$parent    
$name    

ORM\Relation\OneToOne::createRelation

public static function createRelation(
    string $parent, string $name, array $relDef
): ORM\Relation
Factory for relation definition object

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$parent string  
$name string  
$relDef array  

ORM\Relation\OneToOne::createStaticFromAssoc

protected static function createStaticFromAssoc( array $relDef ): static|null
Create static::class from $relDef

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null

Parameters
Parameter Type Description
$relDef array  

ORM\Relation\OneToOne::createStaticFromShort

protected static function createStaticFromShort( array $short ): static|null
Create static::class from $short

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null

Parameters
Parameter Type Description
$short array  

ORM\Relation\OneToOne::deleteRelated

public function deleteRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Delete $entities from association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array<\ORM\Entity>  
$entityManager \ORM\EntityManager  

ORM\Relation\OneToOne::eagerLoad

public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Load this relation for all $entities with one query

Visibility: this method is public.

Parameters
Parameter Type Description
$em \ORM\EntityManager  
$entities \ORM\Entity  

ORM\Relation\OneToOne::fetch

public function fetch(
    ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Fetch the relation

Runs fetch on the EntityManager and returns its result.

Visibility: this method is public.
Returns: this method returns mixed

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\OneToOne::fetchAll

public function fetchAll(
    ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
Fetch all from the relation

Runs fetch and returns EntityFetcher::all() if a Fetcher is returned.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>|\ORM\Entity

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\OneToOne::fromAssoc

protected static function fromAssoc( $parent, array $relDef )
{@inheritDoc}

Static: this method is static.
Visibility: this method is protected.

Parameters
Parameter Type Description
$parent    
$relDef array  

ORM\Relation\OneToOne::fromShort

public static function fromShort( $parent, array $short )
{@inheritDoc}

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$parent    
$short array  

ORM\Relation\OneToOne::getOpponent

protected function getOpponent(
    string $requiredType = null
): ORM\Relation\Owner|ORM\Relation\ManyToMany

Visibility: this method is protected.
Returns: this method returns \ORM\Relation\Owner|\ORM\Relation\ManyToMany
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$requiredType string  

ORM\Relation\OneToOne::setRelated

public function setRelated( ORM\Entity $self, $entity = null )
Set the relation to $entity

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entity \ORM\Entity | null  

ORM\Dbal\Other

Extends: ORM\Dbal\Dbal

Database abstraction for other databases

Properties

Visibility Name Type Description
protected $booleanFalse string  
protected $booleanTrue string  
protected $entityManager ** \ ORM \ EntityManager**  
protected $identifierDivider string  
protected $quotingCharacter string  
protected $transactionCounter integer Number of opened transactions
protected static $typeMapping array  

ORM\Relation\Owner

Extends: ORM\Relation

Owner Relation

Properties

Visibility Name Type Description
protected $class string The class that is related
protected $filters array Filters applied to all fetchers
protected $name string The name of the relation for error messages
protected $parent string The parent entity that defined this relation
protected $reference array Reference definition as key value pairs

Methods

ORM\Relation\Owner::__construct

public function __construct( string $class, array $reference )
Owner constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$class string  
$reference array  

ORM\Relation\Owner::addJoin

public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
{@inheritdoc}

Visibility: this method is public.

Parameters
Parameter Type Description
$fetcher \ORM\EntityFetcher  
$join    
$alias    

ORM\Relation\Owner::addRelated

public function addRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Add $entities to association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array<\ORM\Entity>  
$entityManager \ORM\EntityManager  

ORM\Relation\Owner::apply

public function apply( ORM\EntityFetcher $fetcher, ORM\Entity $entity )
Apply where conditions for $entity on $fetcher

Called from non-owner to find related elements. Example: $user->fetch(‘articles’) creates an EntityFetcher for Article and calls $opponent->apply($fetcher, $user) that will call $fetcher->where(‘authorId’, $user->id)

Visibility: this method is public.

Parameters
Parameter Type Description
$fetcher \ORM\EntityFetcher  
$entity \ORM\Entity  

ORM\Relation\Owner::applyJoin

public function applyJoin(
    ORM\QueryBuilder\Parenthesis $join, string $yourAlias, 
    ORM\Relation\OneToMany $opponent
)
Adds the join clause to the entity fetcher

Visibility: this method is public.

Parameters
Parameter Type Description
$join \ORM\QueryBuilder\Parenthesis  
$yourAlias string  
$opponent OneToMany  

ORM\Relation\Owner::assignForeignObjects

protected function assignForeignObjects(
    array $fkAttributes, array $keyAttributes, array $entities, 
    array $foreignObjects
)
Assign $foreignObjects to $entities mapped by attributes

Visibility: this method is protected.

Parameters
Parameter Type Description
$fkAttributes array  
$keyAttributes array  
$entities array  
$foreignObjects array  

ORM\Relation\Owner::checkBoundTo

protected function checkBoundTo( $parent, $name )
Check if the relation is bound to $parent and throw if not

Visibility: this method is protected.
Throws: this method may throw \ORM\Exception

Parameters
Parameter Type Description
$parent    
$name    

ORM\Relation\Owner::createRelation

public static function createRelation(
    string $parent, string $name, array $relDef
): ORM\Relation
Factory for relation definition object

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$parent string  
$name string  
$relDef array  

ORM\Relation\Owner::deleteRelated

public function deleteRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Delete $entities from association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array<\ORM\Entity>  
$entityManager \ORM\EntityManager  

ORM\Relation\Owner::eagerLoad

public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Load all foreign objects of all $entities with one query

Visibility: this method is public.

Parameters
Parameter Type Description
$em \ORM\EntityManager  
$entities \ORM\Entity  

ORM\Relation\Owner::fetch

public function fetch(
    ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Fetch the relation

Runs fetch on the EntityManager and returns its result.

Visibility: this method is public.
Returns: this method returns mixed

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\Owner::fetchAll

public function fetchAll(
    ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
Fetch all from the relation

Runs fetch and returns EntityFetcher::all() if a Fetcher is returned.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>|\ORM\Entity

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\Owner::fromAssoc

protected static function fromAssoc( $parent, array $relDef )
{@inheritDoc}

Static: this method is static.
Visibility: this method is protected.

Parameters
Parameter Type Description
$parent    
$relDef array  

ORM\Relation\Owner::fromShort

public static function fromShort( $parent, array $short )
{@inheritDoc}

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$parent    
$short array  

ORM\Relation\Owner::getReference

public function getReference()

Visibility: this method is public.

ORM\Relation\Owner::setRelated

public function setRelated( ORM\Entity $self, ORM\Entity $entity = null )
Set the relation to $entity

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation or \ORM\Exception\IncompletePrimaryKey

Parameters
Parameter Type Description
$self \ORM\Entity  
$entity \ORM\Entity  

ORM\Relation\ParentChildren

Extends: ORM\Relation\OneToMany

A parent to children (many)

Properties

Visibility Name Type Description
protected $class string The class that is related
protected $filters array Filters applied to all fetchers
protected $name string The name of the relation for error messages
protected $opponent string The name of the relation in the related class
protected $parent string The parent entity that defined this relation

Methods

ORM\Relation\ParentChildren::__construct

public function __construct(
    string $class, string $opponent, $filters = array()
)
Owner constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$class string  
$opponent string  
$filters array<\ORM\EntityFetcher\FilterInterface> | array<callable>  

ORM\Relation\ParentChildren::addJoin

public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
{@inheritdoc}

Visibility: this method is public.

Parameters
Parameter Type Description
$fetcher \ORM\EntityFetcher  
$join    
$alias    

ORM\Relation\ParentChildren::addRelated

public function addRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Add $entities to association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array<\ORM\Entity>  
$entityManager \ORM\EntityManager  

ORM\Relation\ParentChildren::assignForeignObjects

protected function assignForeignObjects(
    array $fkAttributes, array $keyAttributes, array $entities, 
    array $foreignObjects
)
Assign $foreignObjects to $entities mapped by attributes

Visibility: this method is protected.

Parameters
Parameter Type Description
$fkAttributes array  
$keyAttributes array  
$entities array  
$foreignObjects array  

ORM\Relation\ParentChildren::buildTree

public function buildTree( ORM\Entity $entities ): array<\ORM\Entity>
Set all children and return an array containing the root elements

This method expects you to pass all elements of a branch. Keep in mind that that the array you are getting is not necessarily from the same parent if you are not passing all elements of a branch.

Example of this issue: Elements passed ['1.', '1.2.', '1.3.', '3.5.', '4.'] (each element is represented by its materialized path). As ‘3.’ is not passed, ‘3.5.’ seems to be the root element resulting in the following tree:

[
  [path => '1.', children => [['path' => '1.2.'],['path' => '1.3.']]],
  [path => '3.5.'],
  [path => '4.'],
]

Example usage when you are using materialized paths:

$children = $em->fetch('Category::class')->where('path', 'LIKE', '3.5._%')->all();
$treeOf35 = Category::getRelation('children')->buildTree(...$children);

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Relation\ParentChildren::checkBoundTo

protected function checkBoundTo( $parent, $name )
Check if the relation is bound to $parent and throw if not

Visibility: this method is protected.
Throws: this method may throw \ORM\Exception

Parameters
Parameter Type Description
$parent    
$name    

ORM\Relation\ParentChildren::createRelation

public static function createRelation(
    string $parent, string $name, array $relDef
): ORM\Relation
Factory for relation definition object

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$parent string  
$name string  
$relDef array  

ORM\Relation\ParentChildren::createStaticFromAssoc

protected static function createStaticFromAssoc( array $relDef ): static|null
Create static::class from $relDef

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null

Parameters
Parameter Type Description
$relDef array  

ORM\Relation\ParentChildren::createStaticFromShort

protected static function createStaticFromShort( array $short ): static|null
Create static::class from $short

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null

Parameters
Parameter Type Description
$short array  

ORM\Relation\ParentChildren::deleteRelated

public function deleteRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Delete $entities from association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entities array<\ORM\Entity>  
$entityManager \ORM\EntityManager  

ORM\Relation\ParentChildren::eagerLoad

public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Load this relation for all $entities with one query

Visibility: this method is public.

Parameters
Parameter Type Description
$em \ORM\EntityManager  
$entities \ORM\Entity  

ORM\Relation\ParentChildren::fetch

abstract public function fetch(
    ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Fetch the relation

Runs fetch on the EntityManager and returns its result.

Visibility: this method is public.
Returns: this method returns mixed

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\ParentChildren::fetchAll

public function fetchAll(
    ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
Fetch all from the relation

Runs fetch and returns EntityFetcher::all() if a Fetcher is returned.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>|\ORM\Entity

Parameters
Parameter Type Description
$self \ORM\Entity  
$entityManager \ORM\EntityManager  

ORM\Relation\ParentChildren::fromAssoc

protected static function fromAssoc( $parent, array $relDef )
{@inheritDoc}

Static: this method is static.
Visibility: this method is protected.

Parameters
Parameter Type Description
$parent    
$relDef array  

ORM\Relation\ParentChildren::fromShort

public static function fromShort( $parent, array $short )
{@inheritDoc}

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$parent    
$short array  

ORM\Relation\ParentChildren::getOpponent

protected function getOpponent(
    string $requiredType = null
): ORM\Relation\Owner|ORM\Relation\ManyToMany

Visibility: this method is protected.
Returns: this method returns \ORM\Relation\Owner|\ORM\Relation\ManyToMany
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$requiredType string  

ORM\Relation\ParentChildren::setRelated

public function setRelated( ORM\Entity $self, $entity = null )
Set the relation to $entity

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self \ORM\Entity  
$entity \ORM\Entity | null  

ORM\QueryBuilder\Parenthesis

Implements: ORM\QueryBuilder\ParenthesisInterface

Properties

Visibility Name Type Description
protected $onClose callable Callback to close the parenthesis
protected $parent ParenthesisInterface Parent parenthesis or query
protected $where array<string> Where conditions get concatenated with space

Methods

ORM\QueryBuilder\Parenthesis::__construct

public function __construct(
    callable $onClose, ORM\QueryBuilder\ParenthesisInterface $parent
)
Constructor

Create a parenthesis inside another parenthesis or a query.

Visibility: this method is public.

Parameters
Parameter Type Description
$onClose callable Callable that gets executed when the parenthesis get closed
$parent ParenthesisInterface Parent where createWhereCondition get executed

ORM\QueryBuilder\Parenthesis::andParenthesis

public function andParenthesis(): $this
Add a parenthesis with AND

Visibility: this method is public.
Returns: this method returns $this

ORM\QueryBuilder\Parenthesis::andWhere

public function andWhere(
    string $column, $operator = null, string $value = null
): $this
Add a where condition with AND.

QueryBuilderInterface andWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->andWhere('name', '=' , 'John Doe');
$query->andWhere('name = ?', 'John Doe');
$query->andWhere('name', 'John Doe');
$query->andWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\QueryBuilder\Parenthesis::close

public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Close parenthesis

Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface

ORM\QueryBuilder\Parenthesis::getExpression

public function getExpression(): string
Get the expression

Returns the complete expression inside this parenthesis.

Visibility: this method is public.
Returns: this method returns string

ORM\QueryBuilder\Parenthesis::orParenthesis

public function orParenthesis(): $this
Add a parenthesis with OR

Visibility: this method is public.
Returns: this method returns $this

ORM\QueryBuilder\Parenthesis::orWhere

public function orWhere(
    string $column, $operator = null, string $value = null
): $this
Add a where condition with OR.

QueryBuilderInterface orWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->orWhere('name', '=' , 'John Doe');
$query->orWhere('name = ?', 'John Doe');
$query->orWhere('name', 'John Doe');
$query->orWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\QueryBuilder\Parenthesis::orWhereIn

public function orWhereIn( $column, array $values ): $this
Add a where in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\Parenthesis::orWhereNotIn

public function orWhereNotIn( $column, array $values ): $this
Add a where not in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\Parenthesis::parenthesis

public function parenthesis(): $this
Alias for andParenthesis

Visibility: this method is public.
Returns: this method returns $this

ORM\QueryBuilder\Parenthesis::where

public function where( string $column, $operator = null, $value = null ): $this
Alias for andWhere

QueryBuilderInterface where($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->where('name', '=' , 'John Doe');
$query->where('name = ?', 'John Doe');
$query->where('name', 'John Doe');
$query->where('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator mixed Operator, value or array of values
$value mixed Value (required when used with operator)

See Also:

public function whereIn( $column, array $values ): $this
Add a where in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\Parenthesis::whereNotIn

public function whereNotIn( $column, array $values ): $this
Add a where not in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\Parenthesis::wherePrefix

private function wherePrefix( string $bool ): string
Get the prefix for a where condition or empty if not needed

Visibility: this method is private.
Returns: this method returns string

Parameters
Parameter Type Description
$bool string The prefix to use (‘AND’ or ‘OR’)

ORM\QueryBuilder\ParenthesisInterface

Interface ParenthesisInterface

Methods

ORM\QueryBuilder\ParenthesisInterface::andParenthesis

public function andParenthesis(): $this
Add a parenthesis with AND

Visibility: this method is public.
Returns: this method returns $this

ORM\QueryBuilder\ParenthesisInterface::andWhere

public function andWhere(
    string $column, $operator = '', string $value = ''
): $this
Add a where condition with AND.

QueryBuilderInterface andWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->andWhere('name', '=' , 'John Doe');
$query->andWhere('name = ?', 'John Doe');
$query->andWhere('name', 'John Doe');
$query->andWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\QueryBuilder\ParenthesisInterface::close

public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Close parenthesis

Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface

ORM\QueryBuilder\ParenthesisInterface::getExpression

public function getExpression(): string
Get the expression

Returns the complete expression inside this parenthesis.

Visibility: this method is public.
Returns: this method returns string

ORM\QueryBuilder\ParenthesisInterface::orParenthesis

public function orParenthesis(): $this
Add a parenthesis with OR

Visibility: this method is public.
Returns: this method returns $this

ORM\QueryBuilder\ParenthesisInterface::orWhere

public function orWhere(
    string $column, $operator = '', string $value = ''
): $this
Add a where condition with OR.

QueryBuilderInterface orWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->orWhere('name', '=' , 'John Doe');
$query->orWhere('name = ?', 'John Doe');
$query->orWhere('name', 'John Doe');
$query->orWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\QueryBuilder\ParenthesisInterface::orWhereIn

public function orWhereIn( $column, array $values ): $this
Add a where in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\ParenthesisInterface::orWhereNotIn

public function orWhereNotIn( $column, array $values ): $this
Add a where not in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\ParenthesisInterface::parenthesis

public function parenthesis(): $this
Alias for andParenthesis

Visibility: this method is public.
Returns: this method returns $this

See Also:

public function where( string $column, $operator = '', $value = '' ): $this
Alias for andWhere

QueryBuilderInterface where($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->where('name', '=' , 'John Doe');
$query->where('name = ?', 'John Doe');
$query->where('name', 'John Doe');
$query->where('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator mixed Operator, value or array of values
$value mixed Value (required when used with operator)

See Also:

public function whereIn( $column, array $values ): $this
Add a where in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\ParenthesisInterface::whereNotIn

public function whereNotIn( $column, array $values ): $this
Add a where not in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\Dbal\Pgsql

Extends: ORM\Dbal\Dbal

Database abstraction for PostgreSQL databases

Properties

Visibility Name Type Description
protected $booleanFalse    
protected $booleanTrue    
protected $entityManager ** \ ORM \ EntityManager**  
protected $identifierDivider string  
protected $quotingCharacter string  
protected $transactionCounter integer Number of opened transactions
protected static $typeMapping array  

Methods

ORM\Dbal\Pgsql::__construct

public function __construct(
    ORM\EntityManager $entityManager, array $options = array()
)
Dbal constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$entityManager \ORM\EntityManager  
$options array  

ORM\Dbal\Pgsql::assertSameType

protected static function assertSameType(
    array<\ORM\Entity> $entities
): boolean

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns boolean
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$entities array<\ORM\Entity>  

ORM\Dbal\Pgsql::beginTransaction

public function beginTransaction(): boolean
Begin a transaction or create a savepoint

Visibility: this method is public.
Returns: this method returns boolean

ORM\Dbal\Pgsql::buildDeleteStatement

protected function buildDeleteStatement( $table, array $where )

Visibility: this method is protected.

Parameters
Parameter Type Description
$table    
$where array  

ORM\Dbal\Pgsql::buildInsert

protected function buildInsert( string $table, array $rows ): string
Build an insert statement for $rows

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$table string  
$rows array  

ORM\Dbal\Pgsql::buildSetClause

protected function buildSetClause( array $updates )

Visibility: this method is protected.

Parameters
Parameter Type Description
$updates array  

ORM\Dbal\Pgsql::buildUpdateFromStatement

protected function buildUpdateFromStatement(
    $table, array $where, array $updates, array $joins
)

Visibility: this method is protected.

Parameters
Parameter Type Description
$table    
$where array  
$updates array  
$joins array  

ORM\Dbal\Pgsql::buildUpdateStatement

protected function buildUpdateStatement( $table, array $where, array $updates )

Visibility: this method is protected.

Parameters
Parameter Type Description
$table    
$where array  
$updates array  

ORM\Dbal\Pgsql::commit

public function commit( boolean $all = false ): boolean
Commit the current transaction or decrease the savepoint counter

Actually nothing will be committed if there are savepoints. Instead the counter will be decreased and the commited savepoint will still be rolled back when you call rollback afterwards.

Hopefully that gives a hint why save points are no transactions and what the limitations are.

Begin transaction
  updates / inserts for transaction1
  Create savepoint transaction1
    updates / inserts for transaction2
    Create savepoint transaction2
      updates / inserts for transaction3
    <no commit here but you called commit for transaction3>
    updates / inserts for transaction2
  rollback of transaction2 to savepoint of transaction1
  update / inserts for transaction1
commit of transaction1

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$all boolean Commit all opened transactions and savepoints

ORM\Dbal\Pgsql::convertJoin

protected function convertJoin( $join )

Visibility: this method is protected.

Parameters
Parameter Type Description
$join    

ORM\Dbal\Pgsql::delete

public function delete( string $table, array $where ): integer
Delete rows from $table using $where conditions

Where conditions can be an array of key => value pairs to check for equality or an array of expressions.

Examples: $dbal->delete('someTable', ['id' => 23]) $dbal->delete('user', ['name = \'john\'', 'OR email=\'john.doe@example.com\''])

Tip: Use the query builder to construct where conditions: $em->query('user')->where('name', 'john')->orWhere('email', '...')->delete();

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows

Parameters
Parameter Type Description
$table string The table where to delete rows
$where array An array of where conditions

ORM\Dbal\Pgsql::deleteEntity

public function deleteEntity( ORM\Entity $entity ): boolean
Delete $entity from database

This method does not delete from the map - you can still receive the entity via fetch.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entity \ORM\Entity  

ORM\Dbal\Pgsql::describe

public function describe(
    $schemaTable
): ORM\Dbal\Table|array<\ORM\Dbal\Column>
Describe a table

Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Table|array<mixed,\ORM\Dbal\Column>

Parameters
Parameter Type Description
$schemaTable    

ORM\Dbal\Pgsql::escapeBoolean

protected function escapeBoolean( boolean $value ): string
Escape a boolean for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value boolean  

ORM\Dbal\Pgsql::escapeDateTime

protected function escapeDateTime( DateTime $value ): mixed
Escape a date time object for query

Visibility: this method is protected.
Returns: this method returns mixed

Parameters
Parameter Type Description
$value \DateTime  

ORM\Dbal\Pgsql::escapeDouble

protected function escapeDouble( double $value ): string
Escape a double for Query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value double  

ORM\Dbal\Pgsql::escapeIdentifier

public function escapeIdentifier( string $identifier ): string
Returns $identifier quoted for use in a sql statement

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$identifier string Identifier to quote

ORM\Dbal\Pgsql::escapeInteger

protected function escapeInteger( integer $value ): string
Escape an integer for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value integer  

ORM\Dbal\Pgsql::escapeNULL

protected function escapeNULL(): string
Escape NULL for query

Visibility: this method is protected.
Returns: this method returns string

ORM\Dbal\Pgsql::escapeString

protected function escapeString( string $value ): string
Escape a string for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value string  

ORM\Dbal\Pgsql::escapeValue

public function escapeValue( $value ): string
Returns $value formatted to use in a sql statement.

Visibility: this method is public.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotScalar

Parameters
Parameter Type Description
$value mixed The variable that should be returned in SQL syntax

ORM\Dbal\Pgsql::extractParenthesis

protected function extractParenthesis( string $type ): string
Extract content from parenthesis in $type

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$type string  

ORM\Dbal\Pgsql::insert

public function insert( $table, array $rows )

Visibility: this method is public.

Parameters
Parameter Type Description
$table    
$rows array  

ORM\Dbal\Pgsql::insertAndSync

public function insertAndSync( ORM\Entity $entities ): boolean
Insert $entities and update with default values from database

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns boolean
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Pgsql::insertAndSyncWithAutoInc

public function insertAndSyncWithAutoInc(
    ORM\Entity $entities
): integer|boolean
Insert $entities and sync with auto increment primary key

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns integer|boolean

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Pgsql::insertEntities

public function insertEntities( ORM\Entity $entities ): boolean
Insert $entities into database

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Pgsql::normalizeType

protected function normalizeType( string $type ): string
Normalize $type

The type returned by mysql is for example VARCHAR(20) - this function converts it to varchar

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$type string  

ORM\Dbal\Pgsql::rollback

public function rollback(): boolean
Rollback the current transaction or save point

Visibility: this method is public.
Returns: this method returns boolean

ORM\Dbal\Pgsql::setOption

public function setOption( string $option, $value ): $this
Set $option to $value

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$option string  
$value mixed  

ORM\Dbal\Pgsql::syncInserted

protected function syncInserted( ORM\Entity $entities )
Sync the $entities after insert

Visibility: this method is protected.

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Pgsql::update

public function update(
    string $table, array $where, array $updates, array $joins = array()
): integer
Update $table using $where to set $updates

Simple usage: update('table', ['id' => 23], ['name' => 'John Doe'])

For advanced queries with parenthesis, joins (if supported from your DBMS) etc. use QueryBuilder:

$em->query('table')
 ->where('birth_date', '>', EM::raw('DATE_SUB(NOW(), INTERVAL 18 YEARS)'))
 ->update(['teenager' => true]);

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of affected rows

Parameters
Parameter Type Description
$table string The table to update
$where array An array of where conditions
$updates array An array of columns to update
$joins array For internal use from query builder only

ORM\Dbal\Pgsql::updateAutoincrement

protected function updateAutoincrement( ORM\Entity $entity, $value )
Update the autoincrement value

Visibility: this method is protected.

Parameters
Parameter Type Description
$entity \ORM\Entity  
$value integer | string  

ORM\QueryBuilder\QueryBuilder

Extends: ORM\QueryBuilder\Parenthesis

Implements: ORM\QueryBuilder\QueryBuilderInterface

Build a ansi sql query / select statement

If you need more specific queries you write them yourself. If you need just more specific where clause you can pass them to the *where() methods.

Supported:

Properties

Visibility Name Type Description
protected $alias string The alias of the main table
protected $columns array | null Columns to fetch (null is equal to ['*'])
protected $cursor integer The position of the cursor
public static $defaultEntityManager ** \ ORM \ EntityManager** The default EntityManager to use to for quoting
protected $entityManager ** \ ORM \ EntityManager** EntityManager to use for quoting
protected $groupBy array<string> Group by conditions get concatenated with comma
protected $joins array<string> Joins get concatenated with space
protected $limit integer Limit amount of rows
protected $modifier array<string> Modifiers get concatenated with space
protected $offset integer Offset to start from
protected $onClose callable Callback to close the parenthesis
protected $orderBy array<string> Order by conditions get concatenated with comma
protected $parent ParenthesisInterface Parent parenthesis or query
protected $result ** \ PDOStatement** The result object from PDO
protected $rows array The rows returned
protected $tableName string The table to query
protected $where array<string> Where conditions get concatenated with space

Methods

ORM\QueryBuilder\QueryBuilder::__construct

public function __construct(
    string $tableName, string $alias = '', 
    ORM\EntityManager $entityManager = null
)
Constructor

Create a select statement for $tableName with an object oriented interface.

It uses static::$defaultEntityManager if $entityManager is not given.

Visibility: this method is public.

Parameters
Parameter Type Description
$tableName string The main table to use in FROM clause
$alias string An alias for the table
$entityManager \ORM\EntityManager EntityManager for quoting

ORM\QueryBuilder\QueryBuilder::all

public function all(): mixed|null
Get all rows from the query result

Please note that this will execute the query - further modifications will not have any effect.

If the query fails you should get an exception. Anyway if we couldn’t get a result or there are no rows it returns an empty array.

Visibility: this method is public.
Returns: this method returns mixed|null

ORM\QueryBuilder\QueryBuilder::andParenthesis

public function andParenthesis(): $this
Add a parenthesis with AND

Visibility: this method is public.
Returns: this method returns $this

ORM\QueryBuilder\QueryBuilder::andWhere

public function andWhere(
    string $column, $operator = null, string $value = null
): $this
Add a where condition with AND.

QueryBuilderInterface andWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->andWhere('name', '=' , 'John Doe');
$query->andWhere('name = ?', 'John Doe');
$query->andWhere('name', 'John Doe');
$query->andWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\QueryBuilder\QueryBuilder::close

public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Close parenthesis

Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface

ORM\QueryBuilder\QueryBuilder::column

public function column(
    string $column, array $args = array(), string $alias = ''
): $this
Add $column

Optionally you can provide an expression with question marks as placeholders filled with $args.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression to fetch
$args array Arguments for expression
$alias string Alias for the column

ORM\QueryBuilder\QueryBuilder::columns

public function columns( array $columns = null ): $this
Set $columns

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$columns array  

ORM\QueryBuilder\QueryBuilder::convertPlaceholders

protected function convertPlaceholders( string $expression, $args ): string
Replaces question marks in $expression with $args

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$expression string Expression with placeholders
$args array | mixed Arguments for placeholders

ORM\QueryBuilder\QueryBuilder::delete

public function delete(): integer
Execute a delete statement on the current table with current where conditions

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows

ORM\QueryBuilder\QueryBuilder::fullJoin

public function fullJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Full (outer) join $tableName with $options

When no expression got provided self get returned. If you want to get a parenthesis the parameter empty can be set to false.

ATTENTION: here the default value of empty got changed - defaults to yes

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilder::getDefaultOperator

private function getDefaultOperator( $value ): string
Get the default operator for $value

Arrays use IN by default - all others use =

Visibility: this method is private.
Returns: this method returns string

Parameters
Parameter Type Description
$value mixed The value to determine the operator

ORM\QueryBuilder\QueryBuilder::getEntityManager

public function getEntityManager(): ORM\EntityManager

Visibility: this method is public.
Returns: this method returns \ORM\EntityManager

ORM\QueryBuilder\QueryBuilder::getExpression

public function getExpression(): string
Get the expression

Returns the complete expression inside this parenthesis.

Visibility: this method is public.
Returns: this method returns string

ORM\QueryBuilder\QueryBuilder::getQuery

public function getQuery(): string
Get the query / select statement

Builds the statement from current where conditions, joins, columns and so on.

Visibility: this method is public.
Returns: this method returns string

ORM\QueryBuilder\QueryBuilder::getStatement

protected function getStatement(): PDOStatement|boolean
Query database and return result

Queries the database with current query and returns the resulted PDOStatement.

If query failed it returns false. It also stores this failed result and to change the query afterwards will not change the result.

Visibility: this method is protected.
Returns: this method returns \PDOStatement|boolean

ORM\QueryBuilder\QueryBuilder::groupBy

public function groupBy( string $column, array $args = array() ): $this
Group By $column

Optionally you can provide an expression in $column with question marks as placeholders.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression for groups
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilder::insert

public function insert( array $rows ): integer
Execute an insert statement on the current table

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of inserted rows

Parameters
Parameter Type Description
$rows array  

ORM\QueryBuilder\QueryBuilder::join

public function join(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
(Inner) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilder::leftJoin

public function leftJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Left (outer) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilder::limit

public function limit( integer $limit ): $this
Set $limit

Limits the amount of rows fetched from database.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$limit integer The limit to set

ORM\QueryBuilder\QueryBuilder::modifier

public function modifier( string $modifier ): $this
Add $modifier

Add query modifiers such as SQL_CALC_FOUND_ROWS or DISTINCT.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$modifier string  

ORM\QueryBuilder\QueryBuilder::offset

public function offset( integer $offset ): $this
Set $offset

Changes the offset (only with limit) where fetching starts in the query.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$offset integer The offset to set

ORM\QueryBuilder\QueryBuilder::one

public function one(): mixed|null
Get the next row from the query result

Please note that this will execute the query - further modifications will not have any effect.

If the query fails you should get an exception. Anyway if we couldn’t get a result or there are no more rows it returns null.

Visibility: this method is public.
Returns: this method returns mixed|null

ORM\QueryBuilder\QueryBuilder::orderBy

public function orderBy(
    string $column, string $direction = self::DIRECTION_ASCENDING, 
    array $args = array()
): $this
Order By $column in $direction

Optionally you can provide an expression in $column with question marks as placeholders.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression for order
$direction string Direction (default: ASC)
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilder::orParenthesis

public function orParenthesis(): $this
Add a parenthesis with OR

Visibility: this method is public.
Returns: this method returns $this

ORM\QueryBuilder\QueryBuilder::orWhere

public function orWhere(
    string $column, $operator = null, string $value = null
): $this
Add a where condition with OR.

QueryBuilderInterface orWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->orWhere('name', '=' , 'John Doe');
$query->orWhere('name = ?', 'John Doe');
$query->orWhere('name', 'John Doe');
$query->orWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\QueryBuilder\QueryBuilder::orWhereIn

public function orWhereIn( $column, array $values ): $this
Add a where in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\QueryBuilder::orWhereNotIn

public function orWhereNotIn( $column, array $values ): $this
Add a where not in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\QueryBuilder::parenthesis

public function parenthesis(): $this
Alias for andParenthesis

Visibility: this method is public.
Returns: this method returns $this

ORM\QueryBuilder\QueryBuilder::reset

public function reset(): $this
Reset the position of the cursor to the first row

Visibility: this method is public.
Returns: this method returns $this

ORM\QueryBuilder\QueryBuilder::rightJoin

public function rightJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Right (outer) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilder::setFetchMode

public function setFetchMode(
    integer $mode, $classNameObject = null, array $constructorArgs = null
): $this
Proxy to PDOStatement::setFetchMode()

Please note that this will execute the query - further modifications will not have any effect.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$mode integer one of the PDO::FETCH_ constants
$classNameObject integer | string | object class (FETCH_CLASS), column number (FETCH_COLUMN), object (FETCH_INTO)
$constructorArgs array arguments to pass to the constructor (FETCH_CLASS)

See Also:

public function update( array $updates ): integer
Execute an update statement for the current query

NOTE: not all drivers support UPDATE with JOIN (or FROM). Has to be implemented in the database abstraction layer.

$updates should be an array which columns to update with what value. Use expressions to bypass escaping.

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of affected rows

Parameters
Parameter Type Description
$updates array An array of columns to update

ORM\QueryBuilder\QueryBuilder::where

public function where( string $column, $operator = null, $value = null ): $this
Alias for andWhere

QueryBuilderInterface where($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->where('name', '=' , 'John Doe');
$query->where('name = ?', 'John Doe');
$query->where('name', 'John Doe');
$query->where('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator mixed Operator, value or array of values
$value mixed Value (required when used with operator)

See Also:

public function whereIn( $column, array $values ): $this
Add a where in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\QueryBuilder::whereNotIn

public function whereNotIn( $column, array $values ): $this
Add a where not in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\QueryBuilder::wherePrefix

private function wherePrefix( string $bool ): string
Get the prefix for a where condition or empty if not needed

Visibility: this method is private.
Returns: this method returns string

Parameters
Parameter Type Description
$bool string The prefix to use (‘AND’ or ‘OR’)

ORM\QueryBuilder\QueryBuilderInterface

Extends: ORM\QueryBuilder\ParenthesisInterface

Interface QueryBuilderInterface

Constants

Name Value
DIRECTION_ASCENDING 'ASC'
DIRECTION_DESCENDING 'DESC'

Methods

ORM\QueryBuilder\QueryBuilderInterface::andParenthesis

public function andParenthesis(): $this
Add a parenthesis with AND

Visibility: this method is public.
Returns: this method returns $this

ORM\QueryBuilder\QueryBuilderInterface::andWhere

public function andWhere(
    string $column, $operator = '', string $value = ''
): $this
Add a where condition with AND.

QueryBuilderInterface andWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->andWhere('name', '=' , 'John Doe');
$query->andWhere('name = ?', 'John Doe');
$query->andWhere('name', 'John Doe');
$query->andWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\QueryBuilder\QueryBuilderInterface::close

public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Close parenthesis

Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface

ORM\QueryBuilder\QueryBuilderInterface::column

public function column(
    string $column, array $args = array(), string $alias = ''
): $this
Add $column

Optionally you can provide an expression with question marks as placeholders filled with $args.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression to fetch
$args array Arguments for expression
$alias string Alias for the column

ORM\QueryBuilder\QueryBuilderInterface::columns

public function columns( $columns = null ): $this
Set $columns

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$columns array | null  

ORM\QueryBuilder\QueryBuilderInterface::fullJoin

public function fullJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Full (outer) join $tableName with $options

When no expression got provided self get returned. If you want to get a parenthesis the parameter empty can be set to false.

ATTENTION: here the default value of empty got changed - defaults to yes

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilderInterface::getExpression

public function getExpression(): string
Get the expression

Returns the complete expression inside this parenthesis.

Visibility: this method is public.
Returns: this method returns string

ORM\QueryBuilder\QueryBuilderInterface::getQuery

public function getQuery(): string
Get the query / select statement

Builds the statement from current where conditions, joins, columns and so on.

Visibility: this method is public.
Returns: this method returns string

ORM\QueryBuilder\QueryBuilderInterface::groupBy

public function groupBy( string $column, array $args = array() ): $this
Group By $column

Optionally you can provide an expression in $column with question marks as placeholders.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression for groups
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilderInterface::join

public function join(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
(Inner) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilderInterface::leftJoin

public function leftJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Left (outer) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilderInterface::limit

public function limit( integer $limit ): $this
Set $limit

Limits the amount of rows fetched from database.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$limit integer The limit to set

ORM\QueryBuilder\QueryBuilderInterface::modifier

public function modifier( string $modifier ): $this
Add $modifier

Add query modifiers such as SQL_CALC_FOUND_ROWS or DISTINCT.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$modifier string  

ORM\QueryBuilder\QueryBuilderInterface::offset

public function offset( integer $offset ): $this
Set $offset

Changes the offset (only with limit) where fetching starts in the query.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$offset integer The offset to set

ORM\QueryBuilder\QueryBuilderInterface::orderBy

public function orderBy(
    string $column, string $direction = self::DIRECTION_ASCENDING, 
    array $args = array()
): $this
Order By $column in $direction

Optionally you can provide an expression in $column with question marks as placeholders.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression for order
$direction string Direction (default: ASC)
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilderInterface::orParenthesis

public function orParenthesis(): $this
Add a parenthesis with OR

Visibility: this method is public.
Returns: this method returns $this

ORM\QueryBuilder\QueryBuilderInterface::orWhere

public function orWhere(
    string $column, $operator = '', string $value = ''
): $this
Add a where condition with OR.

QueryBuilderInterface orWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->orWhere('name', '=' , 'John Doe');
$query->orWhere('name = ?', 'John Doe');
$query->orWhere('name', 'John Doe');
$query->orWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\QueryBuilder\QueryBuilderInterface::orWhereIn

public function orWhereIn( $column, array $values ): $this
Add a where in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\QueryBuilderInterface::orWhereNotIn

public function orWhereNotIn( $column, array $values ): $this
Add a where not in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\QueryBuilderInterface::parenthesis

public function parenthesis(): $this
Alias for andParenthesis

Visibility: this method is public.
Returns: this method returns $this

See Also:

public function rightJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Right (outer) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\QueryBuilder\QueryBuilderInterface::where

public function where( string $column, $operator = '', $value = '' ): $this
Alias for andWhere

QueryBuilderInterface where($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->where('name', '=' , 'John Doe');
$query->where('name = ?', 'John Doe');
$query->where('name', 'John Doe');
$query->where('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator mixed Operator, value or array of values
$value mixed Value (required when used with operator)

See Also:

public function whereIn( $column, array $values ): $this
Add a where in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\QueryBuilder\QueryBuilderInterface::whereNotIn

public function whereNotIn( $column, array $values ): $this
Add a where not in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\Relation

Base Relation

Constants

Name Value
OPT_CLASS 'class'
OPT_MORPH_COLUMN 'morphColumn'
OPT_MORPH 'morph'
OPT_REFERENCE 'reference'
OPT_CARDINALITY 'cardinality'
OPT_OPPONENT 'opponent'
OPT_TABLE 'table'
OPT_FILTERS 'filters'
CARDINALITY_ONE 'one'
CARDINALITY_MANY 'many'

Properties

Visibility Name Type Description
protected $class string The class that is related
protected $filters array Filters applied to all fetchers
protected $name string The name of the relation for error messages
protected $parent string The parent entity that defined this relation

Methods

ORM\Relation::addRelated

public function addRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Add $entities to association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self Entity  
$entities array<Entity>  
$entityManager EntityManager  

ORM\Relation::assignForeignObjects

protected function assignForeignObjects(
    array $fkAttributes, array $keyAttributes, array $entities, 
    array $foreignObjects
)
Assign $foreignObjects to $entities mapped by attributes

Visibility: this method is protected.

Parameters
Parameter Type Description
$fkAttributes array  
$keyAttributes array  
$entities array  
$foreignObjects array  

ORM\Relation::checkBoundTo

protected function checkBoundTo( $parent, $name )
Check if the relation is bound to $parent and throw if not

Visibility: this method is protected.
Throws: this method may throw \ORM\Exception

Parameters
Parameter Type Description
$parent    
$name    

ORM\Relation::createRelation

public static function createRelation(
    string $parent, string $name, array $relDef
): ORM\Relation
Factory for relation definition object

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration

Parameters
Parameter Type Description
$parent string  
$name string  
$relDef array  

ORM\Relation::deleteRelated

public function deleteRelated(
    ORM\Entity $self, array<\ORM\Entity> $entities, 
    ORM\EntityManager $entityManager
)
Delete $entities from association table

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self Entity  
$entities array<Entity>  
$entityManager EntityManager  

ORM\Relation::eagerLoad

public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Load this relation for all $entities with one query

Visibility: this method is public.

Parameters
Parameter Type Description
$em EntityManager  
$entities Entity  

ORM\Relation::fetch

abstract public function fetch(
    ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Fetch the relation

Runs fetch on the EntityManager and returns its result.

Visibility: this method is public.
Returns: this method returns mixed

Parameters
Parameter Type Description
$self Entity  
$entityManager EntityManager  

ORM\Relation::fetchAll

public function fetchAll(
    ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
Fetch all from the relation

Runs fetch and returns EntityFetcher::all() if a Fetcher is returned.

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>|\ORM\Entity

Parameters
Parameter Type Description
$self Entity  
$entityManager EntityManager  

ORM\Relation::setRelated

public function setRelated( ORM\Entity $self, $entity = null )
Set the relation to $entity

Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation

Parameters
Parameter Type Description
$self Entity  
$entity Entity | null  

ORM\Testing\EntityFetcherMock\Result

Extends: ORM\EntityFetcher

Fetch entities from database

If you need more specific queries you write them yourself. If you need just more specific where clause you can pass them to the *where() methods.

Supported:

Properties

Visibility Name Type Description
protected $alias string The alias of the main table
protected $class string | \ ORM \ Entity The entity class that we want to fetch
protected $classMapping array<string[]> The class to alias mapping and vise versa
protected $columns array | null Columns to fetch (null is equal to ['*'])
protected $cursor integer The position of the cursor
public static $defaultEntityManager ** \ ORM \ EntityManager** The default EntityManager to use to for quoting
protected $eagerLoad array An array or relations that should be loaded
protected $entities array< \ ORM \ Entity>  
protected $entityManager ** \ ORM \ EntityManager** EntityManager to use for quoting
protected $excludedFilters array<string> A list of filters that should not be applied for this fetcher
protected $filters array< \ ORM \ EntityFetcher \ FilterInterface> A list of filters to apply additionally
protected $filtersApplied boolean Boolean if the filters where applied
protected static $globalFilters array< \ ORM \ EntityFetcher \ FilterInterface[]> Filters that always should be applied for an entity
protected $groupBy array<string> Group by conditions get concatenated with comma
protected $joins array<string> Joins get concatenated with space
protected $limit integer Limit amount of rows
protected $modifier array<string> Modifiers get concatenated with space
protected $offset integer Offset to start from
protected $onClose callable Callback to close the parenthesis
protected $orderBy array<string> Order by conditions get concatenated with comma
protected $parent ** \ ORM \ QueryBuilder \ ParenthesisInterface** Parent parenthesis or query
protected $query string | \ ORM \ QueryBuilder \ QueryBuilderInterface The query to execute (overwrites other settings)
protected $regularExpressions array<string>  
protected $result ** \ PDOStatement** The result object from PDO
protected $rows array The rows returned
protected $tableName string The table to query
protected $where array<string> Where conditions get concatenated with space

Methods

ORM\Testing\EntityFetcherMock\Result::__construct

public function __construct(
    callable $onClose, ORM\QueryBuilder\ParenthesisInterface $parent
)
Constructor

Create a parenthesis inside another parenthesis or a query.

Visibility: this method is public.

Parameters
Parameter Type Description
$onClose callable Callable that gets executed when the parenthesis get closed
$parent \ORM\QueryBuilder\ParenthesisInterface Parent where createWhereCondition get executed

ORM\Testing\EntityFetcherMock\Result::addEntities

public function addEntities( array<\ORM\Entity> $entities ): $this
Add entities to the result

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$entities array<\ORM\Entity>  

ORM\Testing\EntityFetcherMock\Result::all

public function all(): mixed|null
Get all rows from the query result

Please note that this will execute the query - further modifications will not have any effect.

If the query fails you should get an exception. Anyway if we couldn’t get a result or there are no rows it returns an empty array.

Visibility: this method is public.
Returns: this method returns mixed|null

ORM\Testing\EntityFetcherMock\Result::andParenthesis

public function andParenthesis(): $this
Add a parenthesis with AND

Visibility: this method is public.
Returns: this method returns $this

ORM\Testing\EntityFetcherMock\Result::andWhere

public function andWhere(
    string $column, $operator = null, string $value = null
): $this
Add a where condition with AND.

QueryBuilderInterface andWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->andWhere('name', '=' , 'John Doe');
$query->andWhere('name = ?', 'John Doe');
$query->andWhere('name', 'John Doe');
$query->andWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\Testing\EntityFetcherMock\Result::applyFilters

protected function applyFilters()
Apply the filters on $this

Visibility: this method is protected.

ORM\Testing\EntityFetcherMock\Result::close

public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Close parenthesis

Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface

ORM\Testing\EntityFetcherMock\Result::column

public function column(
    string $column, array $args = array(), string $alias = ''
): $this
Add $column

Optionally you can provide an expression with question marks as placeholders filled with $args.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression to fetch
$args array Arguments for expression
$alias string Alias for the column

ORM\Testing\EntityFetcherMock\Result::columns

public function columns( array $columns = null ): $this
Set $columns

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$columns array  

ORM\Testing\EntityFetcherMock\Result::compare

public function compare( ORM\EntityFetcher $fetcher ): integer
Check if $fetcher matches the current query

Returns the score for the given EntityFetcher. The more conditions match the higher the score:

Visibility: this method is public.
Returns: this method returns integer

Parameters
Parameter Type Description
$fetcher \ORM\EntityFetcher  

ORM\Testing\EntityFetcherMock\Result::convertPlaceholders

protected function convertPlaceholders( string $expression, $args ): string
Replaces question marks in $expression with $args

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$expression string Expression with placeholders
$args array | mixed Arguments for placeholders

ORM\Testing\EntityFetcherMock\Result::count

public function count(): integer
Get the count of the resulting items

Visibility: this method is public.
Returns: this method returns integer

ORM\Testing\EntityFetcherMock\Result::createRelatedJoin

public function createRelatedJoin( $join, $relation ): $this
Create the join with $join type

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$join    
$relation    

ORM\Testing\EntityFetcherMock\Result::delete

public function delete(): integer
Execute a delete statement on the current table with current where conditions

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows

ORM\Testing\EntityFetcherMock\Result::filter

public function filter( $filter ): $this
Apply an additional $filter before executing

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$filter string | \ORM\EntityFetcher\FilterInterface | callable  

ORM\Testing\EntityFetcherMock\Result::fullJoin

public function fullJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Full (outer) join $tableName with $options

When no expression got provided self get returned. If you want to get a parenthesis the parameter empty can be set to false.

ATTENTION: here the default value of empty got changed - defaults to yes

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\Testing\EntityFetcherMock\Result::getDefaultOperator

private function getDefaultOperator( $value ): string
Get the default operator for $value

Arrays use IN by default - all others use =

Visibility: this method is private.
Returns: this method returns string

Parameters
Parameter Type Description
$value mixed The value to determine the operator

ORM\Testing\EntityFetcherMock\Result::getEntities

public function getEntities(): array<\ORM\Entity>
Get the entities for this result

Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>

ORM\Testing\EntityFetcherMock\Result::getEntityManager

public function getEntityManager(): ORM\EntityManager

Visibility: this method is public.
Returns: this method returns \ORM\EntityManager

ORM\Testing\EntityFetcherMock\Result::getExpression

public function getExpression(): string
Get the expression

Returns the complete expression inside this parenthesis.

Visibility: this method is public.
Returns: this method returns string

ORM\Testing\EntityFetcherMock\Result::getGlobalFilters

public static function getGlobalFilters( string $class ): array
Get the filters registered for $class

A filter can be registered for the super class too.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns array

Parameters
Parameter Type Description
$class string  

ORM\Testing\EntityFetcherMock\Result::getQuery

public function getQuery(): string
Get the query / select statement

Builds the statement from current where conditions, joins, columns and so on.

Visibility: this method is public.
Returns: this method returns string

ORM\Testing\EntityFetcherMock\Result::getStatement

protected function getStatement(): PDOStatement|boolean
Query database and return result

Queries the database with current query and returns the resulted PDOStatement.

If query failed it returns false. It also stores this failed result and to change the query afterwards will not change the result.

Visibility: this method is protected.
Returns: this method returns \PDOStatement|boolean

ORM\Testing\EntityFetcherMock\Result::getTableAndAlias

protected function getTableAndAlias( string $class, string $alias = '' ): array
Get the table name and alias for a class

Visibility: this method is protected.
Returns: this method returns array
Response description: [$table, $alias]

Parameters
Parameter Type Description
$class string  
$alias string  

ORM\Testing\EntityFetcherMock\Result::groupBy

public function groupBy( string $column, array $args = array() ): $this
Group By $column

Optionally you can provide an expression in $column with question marks as placeholders.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression for groups
$args array Arguments for expression

ORM\Testing\EntityFetcherMock\Result::insert

public function insert( array $rows ): integer
Execute an insert statement on the current table

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of inserted rows

Parameters
Parameter Type Description
$rows array  

ORM\Testing\EntityFetcherMock\Result::join

public function join(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
(Inner) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\Testing\EntityFetcherMock\Result::joinRelated

public function joinRelated( $relation ): $this
Join $relation

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$relation    

ORM\Testing\EntityFetcherMock\Result::leftJoin

public function leftJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Left (outer) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\Testing\EntityFetcherMock\Result::leftJoinRelated

public function leftJoinRelated( $relation ): $this
Left outer join $relation

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$relation    

ORM\Testing\EntityFetcherMock\Result::limit

public function limit( integer $limit ): $this
Set $limit

Limits the amount of rows fetched from database.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$limit integer The limit to set

ORM\Testing\EntityFetcherMock\Result::matches

public function matches( string $expression ): $this
Add a regular expression that has to match

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$expression string  

ORM\Testing\EntityFetcherMock\Result::modifier

public function modifier( string $modifier ): $this
Add $modifier

Add query modifiers such as SQL_CALC_FOUND_ROWS or DISTINCT.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$modifier string  

ORM\Testing\EntityFetcherMock\Result::normalizeFilter

protected static function normalizeFilter(
    $filter
): ORM\EntityFetcher\FilterInterface
Converts callables into a CallableFilter and class names into instances

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns \ORM\EntityFetcher\FilterInterface
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$filter string | \ORM\EntityFetcher\FilterInterface | callable  

ORM\Testing\EntityFetcherMock\Result::offset

public function offset( integer $offset ): $this
Set $offset

Changes the offset (only with limit) where fetching starts in the query.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$offset integer The offset to set

ORM\Testing\EntityFetcherMock\Result::one

public function one(): mixed|null
Get the next row from the query result

Please note that this will execute the query - further modifications will not have any effect.

If the query fails you should get an exception. Anyway if we couldn’t get a result or there are no more rows it returns null.

Visibility: this method is public.
Returns: this method returns mixed|null

ORM\Testing\EntityFetcherMock\Result::orderBy

public function orderBy(
    string $column, string $direction = self::DIRECTION_ASCENDING, 
    array $args = array()
): $this
Order By $column in $direction

Optionally you can provide an expression in $column with question marks as placeholders.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression for order
$direction string Direction (default: ASC)
$args array Arguments for expression

ORM\Testing\EntityFetcherMock\Result::orParenthesis

public function orParenthesis(): $this
Add a parenthesis with OR

Visibility: this method is public.
Returns: this method returns $this

ORM\Testing\EntityFetcherMock\Result::orWhere

public function orWhere(
    string $column, $operator = null, string $value = null
): $this
Add a where condition with OR.

QueryBuilderInterface orWhere($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->orWhere('name', '=' , 'John Doe');
$query->orWhere('name = ?', 'John Doe');
$query->orWhere('name', 'John Doe');
$query->orWhere('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator string | array Operator, value or array of values
$value string Value (required when used with operator)

ORM\Testing\EntityFetcherMock\Result::orWhereIn

public function orWhereIn( $column, array $values ): $this
Add a where in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\Testing\EntityFetcherMock\Result::orWhereNotIn

public function orWhereNotIn( $column, array $values ): $this
Add a where not in condition with OR.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\Testing\EntityFetcherMock\Result::parenthesis

public function parenthesis(): $this
Alias for andParenthesis

Visibility: this method is public.
Returns: this method returns $this

ORM\Testing\EntityFetcherMock\Result::registerGlobalFilter

public static function registerGlobalFilter( $class, $filter )
Register $filter globally for $class

A registered filter will be applied in all entity fetchers for the class if not excluded by $fetcher->withoutFilter(Filter::class).

Static: this method is static.
Visibility: this method is public.

Parameters
Parameter Type Description
$class    
$filter string | \ORM\EntityFetcher\FilterInterface | callable  

ORM\Testing\EntityFetcherMock\Result::reset

public function reset(): $this
Reset the position of the cursor to the first row

Visibility: this method is public.
Returns: this method returns $this

ORM\Testing\EntityFetcherMock\Result::rightJoin

public function rightJoin(
    string $tableName, $expression = '', string $alias = '', 
    array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
Right (outer) join $tableName with $options

When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.

Visibility: this method is public.
Returns: this method returns $this|\ORM\QueryBuilder\ParenthesisInterface

Parameters
Parameter Type Description
$tableName string Table to join
$expression string | boolean Expression, single column name or boolean to create an empty join
$alias string Alias for the table
$args array Arguments for expression

ORM\Testing\EntityFetcherMock\Result::setFetchMode

public function setFetchMode(
    integer $mode, $classNameObject = null, array $constructorArgs = null
): $this
Proxy to PDOStatement::setFetchMode()

Please note that this will execute the query - further modifications will not have any effect.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$mode integer one of the PDO::FETCH_ constants
$classNameObject integer | string | object class (FETCH_CLASS), column number (FETCH_COLUMN), object (FETCH_INTO)
$constructorArgs array arguments to pass to the constructor (FETCH_CLASS)

See Also:

public function setQuery( $query, array $args = null ): $this
Set a raw query or use different QueryBuilder

For easier use and against sql injection it allows question mark placeholders.

Please be aware that this query is not touched at all and neither filters nor where conditions are applied.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$query string | \ORM\QueryBuilder\QueryBuilderInterface Raw query string or a QueryBuilderInterface
$args array The arguments for placeholders

ORM\Testing\EntityFetcherMock\Result::toClassAndAlias

private function toClassAndAlias( array $match ): array
Get class and alias by the match from translateColumn

Visibility: this method is private.
Returns: this method returns array
Response description: [$class, $alias]
Throws: this method may throw \ORM\Exception\NotJoined

Parameters
Parameter Type Description
$match array  

ORM\Testing\EntityFetcherMock\Result::translateColumn

protected function translateColumn( string $expression ): string
Translate attribute names in an expression to their column names

Visibility: this method is protected.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotJoined

Parameters
Parameter Type Description
$expression string  

ORM\Testing\EntityFetcherMock\Result::update

public function update( array $updates ): integer
Execute an update statement for the current query

NOTE: not all drivers support UPDATE with JOIN (or FROM). Has to be implemented in the database abstraction layer.

$updates should be an array which columns to update with what value. Use expressions to bypass escaping.

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of affected rows

Parameters
Parameter Type Description
$updates array An array of columns to update

ORM\Testing\EntityFetcherMock\Result::where

public function where( string $column, $operator = null, $value = null ): $this
Alias for andWhere

QueryBuilderInterface where($column[, $operator[, $value]]);

If $column has the same amount of question marks as $value - $value is the second parameter.

If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.

These calls are equal:

$query->where('name', '=' , 'John Doe');
$query->where('name = ?', 'John Doe');
$query->where('name', 'John Doe');
$query->where('name = ?', ['John Doe']);

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string Column or expression with placeholders
$operator mixed Operator, value or array of values
$value mixed Value (required when used with operator)

See Also:

public function whereIn( $column, array $values ): $this
Add a where in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 0 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\Testing\EntityFetcherMock\Result::whereNotIn

public function whereNotIn( $column, array $values ): $this
Add a where not in condition with AND.

If $column is an array a composite where in statement will be created

Example: whereIn(['a', 'b'], [[42, 23], [42, 23]]) gets (a,b) NOT IN ((42,23), (23,42)) in mysql

If $values is empty the expression will be 1 = 1 because an empty parenthesis causes an error in SQL.

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$column string | array  
$values array  

ORM\Testing\EntityFetcherMock\Result::wherePrefix

private function wherePrefix( string $bool ): string
Get the prefix for a where condition or empty if not needed

Visibility: this method is private.
Returns: this method returns string

Parameters
Parameter Type Description
$bool string The prefix to use (‘AND’ or ‘OR’)

ORM\Testing\EntityFetcherMock\Result::with

public function with( string $relations ): $this
Load $relations after all objects are loaded

The relations are only loaded after you execute ->all()

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$relations string  

ORM\Testing\EntityFetcherMock\Result::withoutFilter

public function withoutFilter( string $filterClass ): $this
Exclude $filterClass for this fetcher

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$filterClass string  

ORM\Testing\EntityFetcherMock\ResultRepository

Constants

Name Value
RANDOM_KEY_MIN 1000000000
RANDOM_KEY_MAX 1000999999

Properties

Visibility Name Type Description
protected $em ** \ ORM \ EntityManager**  
protected $primaryKeyMap array< \ ORM \ Entity[]>  
protected $results array<Result[]>  

Methods

ORM\Testing\EntityFetcherMock\ResultRepository::__construct

public function __construct( ORM\EntityManager $em )
ResultRepository constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$em \ORM\EntityManager  

ORM\Testing\EntityFetcherMock\ResultRepository::addEntity

public function addEntity( ORM\Entity $entity )
Add an entity to be fetched by primary key

The entity needs to have a primary key if not it will be filled with random values between RANDOM_KEY_MIN and RANDOM_KEY_MAX (at the time writing this it is 1000000000 and 1000999999).

You can pass mocks from Entity too but we need to call Entity::getPrimaryKey().

Visibility: this method is public.

Parameters
Parameter Type Description
$entity \ORM\Entity  

ORM\Testing\EntityFetcherMock\ResultRepository::addResult

public function addResult(
    $class, ORM\Entity $entities
): ORM\Testing\EntityFetcherMock\Result|Mockery\MockInterface
Create and add a EntityFetcherMock\Result for $class

As the results are mocked to come from the database they will also get a primary key if they don’t have already.

Visibility: this method is public.
Returns: this method returns \ORM\Testing\EntityFetcherMock\Result|\Mockery\MockInterface

Parameters
Parameter Type Description
$class    
$entities \ORM\Entity  

ORM\Testing\EntityFetcherMock\ResultRepository::buildChecksum

protected static function buildChecksum( array $primaryKey ): string
Build a checksum from $primaryKey

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$primaryKey array  

ORM\Testing\EntityFetcherMock\ResultRepository::completePrimaryKeys

public static function completePrimaryKeys(
    ORM\Entity $entities
): array<\ORM\Entity>
Fill the primary keys of $entities

If the primary key is incomplete the missing attributes will be filled with a random integer between RANDOM_KEY_MIN and RANDOM_KEY_MAX (at the time writing this it is 1000000000 and 1000999999).

Static: this method is static.
Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Testing\EntityFetcherMock\ResultRepository::getResults

public function getResults( string $class, ORM\EntityFetcher $fetcher ): array
Get the results for $class and $query

The EntityFetcherMock\Result gets a quality for matching this query. Only the highest quality will be used.

Visibility: this method is public.
Returns: this method returns array

Parameters
Parameter Type Description
$class string  
$fetcher \ORM\EntityFetcher  

ORM\Testing\EntityFetcherMock\ResultRepository::retrieve

public function retrieve( string $class, array $primaryKey ): ORM\Entity|null
Retrieve an entity by $primaryKey

Visibility: this method is public.
Returns: this method returns \ORM\Entity|null

Parameters
Parameter Type Description
$class string  
$primaryKey array  

ORM\Event\Saved

Extends: ORM\Event

Constants

Name Value
NAME 'saved'

Properties

Visibility Name Type Description
protected $data array  
protected $entity ** \ ORM \ Entity**  
protected $originalEvent ** \ ORM \ Event**  
protected $stopped boolean  

Methods

ORM\Event\Saved::__construct

public function __construct( ORM\Event $originalEvent )

Visibility: this method is public.

Parameters
Parameter Type Description
$originalEvent \ORM\Event  

ORM\Event\Saved::__get

public function __get( $name )

Visibility: this method is public.

Parameters
Parameter Type Description
$name    

ORM\Event\Saved::stop

public function stop()

Visibility: this method is public.


ORM\Event\Saving

Extends: ORM\Event

Constants

Name Value
NAME 'saving'

Properties

Visibility Name Type Description
protected $data array  
protected $entity ** \ ORM \ Entity**  
protected $stopped boolean  

ORM\Dbal\Type\Set

Extends: ORM\Dbal\Type\Enum

Set data type

Properties

Visibility Name Type Description
protected $allowedValues array<string>  
protected $type    

Methods

ORM\Dbal\Type\Set::__construct

public function __construct( array<string> $allowedValues )
Set constructor

Visibility: this method is public.

Parameters
Parameter Type Description
$allowedValues array<string>  

ORM\Dbal\Type\Set::factory

public static function factory(
    ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
Returns a new Type object

This method is only for types covered by mapping. Use fromDefinition instead for custom types.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns static

Parameters
Parameter Type Description
$dbal \ORM\Dbal\Dbal  
$columnDefinition array  

ORM\Dbal\Type\Set::fits

public static function fits( array $columnDefinition ): boolean
Check if this type fits to $columnDefinition

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$columnDefinition array  

ORM\Dbal\Type\Set::getAllowedValues

public function getAllowedValues(): array<string>

Visibility: this method is public.
Returns: this method returns array<mixed,string>

ORM\Dbal\Type\Set::validate

public function validate( $value ): boolean|ORM\Dbal\Error
Check if $value is valid for this type

Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error

Parameters
Parameter Type Description
$value mixed  

ORM\Dbal\Sqlite

Extends: ORM\Dbal\Dbal

Database abstraction for SQLite databases

Properties

Visibility Name Type Description
protected $booleanFalse string  
protected $booleanTrue string  
protected $entityManager ** \ ORM \ EntityManager**  
protected $identifierDivider string  
protected $quotingCharacter string  
protected $transactionCounter integer Number of opened transactions
protected static $typeMapping array  

Methods

ORM\Dbal\Sqlite::__construct

public function __construct(
    ORM\EntityManager $entityManager, array $options = array()
)
Dbal constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$entityManager \ORM\EntityManager  
$options array  

ORM\Dbal\Sqlite::assertSameType

protected static function assertSameType(
    array<\ORM\Entity> $entities
): boolean

Static: this method is static.
Visibility: this method is protected.
Returns: this method returns boolean
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$entities array<\ORM\Entity>  

ORM\Dbal\Sqlite::beginTransaction

public function beginTransaction(): boolean
Begin a transaction or create a savepoint

Visibility: this method is public.
Returns: this method returns boolean

ORM\Dbal\Sqlite::buildDeleteStatement

protected function buildDeleteStatement( $table, array $where )

Visibility: this method is protected.

Parameters
Parameter Type Description
$table    
$where array  

ORM\Dbal\Sqlite::buildInsert

protected function buildInsert( string $table, array $rows ): string
Build an insert statement for $rows

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$table string  
$rows array  

ORM\Dbal\Sqlite::buildSetClause

protected function buildSetClause( array $updates )

Visibility: this method is protected.

Parameters
Parameter Type Description
$updates array  

ORM\Dbal\Sqlite::buildUpdateFromStatement

protected function buildUpdateFromStatement(
    $table, array $where, array $updates, array $joins
)

Visibility: this method is protected.

Parameters
Parameter Type Description
$table    
$where array  
$updates array  
$joins array  

ORM\Dbal\Sqlite::buildUpdateStatement

protected function buildUpdateStatement( $table, array $where, array $updates )

Visibility: this method is protected.

Parameters
Parameter Type Description
$table    
$where array  
$updates array  

ORM\Dbal\Sqlite::commit

public function commit( boolean $all = false ): boolean
Commit the current transaction or decrease the savepoint counter

Actually nothing will be committed if there are savepoints. Instead the counter will be decreased and the commited savepoint will still be rolled back when you call rollback afterwards.

Hopefully that gives a hint why save points are no transactions and what the limitations are.

Begin transaction
  updates / inserts for transaction1
  Create savepoint transaction1
    updates / inserts for transaction2
    Create savepoint transaction2
      updates / inserts for transaction3
    <no commit here but you called commit for transaction3>
    updates / inserts for transaction2
  rollback of transaction2 to savepoint of transaction1
  update / inserts for transaction1
commit of transaction1

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$all boolean Commit all opened transactions and savepoints

ORM\Dbal\Sqlite::convertJoin

protected function convertJoin( $join )

Visibility: this method is protected.

Parameters
Parameter Type Description
$join    

ORM\Dbal\Sqlite::delete

public function delete( string $table, array $where ): integer
Delete rows from $table using $where conditions

Where conditions can be an array of key => value pairs to check for equality or an array of expressions.

Examples: $dbal->delete('someTable', ['id' => 23]) $dbal->delete('user', ['name = \'john\'', 'OR email=\'john.doe@example.com\''])

Tip: Use the query builder to construct where conditions: $em->query('user')->where('name', 'john')->orWhere('email', '...')->delete();

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows

Parameters
Parameter Type Description
$table string The table where to delete rows
$where array An array of where conditions

ORM\Dbal\Sqlite::deleteEntity

public function deleteEntity( ORM\Entity $entity ): boolean
Delete $entity from database

This method does not delete from the map - you can still receive the entity via fetch.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entity \ORM\Entity  

ORM\Dbal\Sqlite::describe

public function describe(
    $schemaTable
): ORM\Dbal\Table|array<\ORM\Dbal\Column>
Describe a table

Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Table|array<mixed,\ORM\Dbal\Column>

Parameters
Parameter Type Description
$schemaTable    

ORM\Dbal\Sqlite::escapeBoolean

protected function escapeBoolean( boolean $value ): string
Escape a boolean for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value boolean  

ORM\Dbal\Sqlite::escapeDateTime

protected function escapeDateTime( DateTime $value ): mixed
Escape a date time object for query

Visibility: this method is protected.
Returns: this method returns mixed

Parameters
Parameter Type Description
$value \DateTime  

ORM\Dbal\Sqlite::escapeDouble

protected function escapeDouble( double $value ): string
Escape a double for Query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value double  

ORM\Dbal\Sqlite::escapeIdentifier

public function escapeIdentifier( string $identifier ): string
Returns $identifier quoted for use in a sql statement

Visibility: this method is public.
Returns: this method returns string

Parameters
Parameter Type Description
$identifier string Identifier to quote

ORM\Dbal\Sqlite::escapeInteger

protected function escapeInteger( integer $value ): string
Escape an integer for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value integer  

ORM\Dbal\Sqlite::escapeNULL

protected function escapeNULL(): string
Escape NULL for query

Visibility: this method is protected.
Returns: this method returns string

ORM\Dbal\Sqlite::escapeString

protected function escapeString( string $value ): string
Escape a string for query

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$value string  

ORM\Dbal\Sqlite::escapeValue

public function escapeValue( $value ): string
Returns $value formatted to use in a sql statement.

Visibility: this method is public.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotScalar

Parameters
Parameter Type Description
$value mixed The variable that should be returned in SQL syntax

ORM\Dbal\Sqlite::extractParenthesis

protected function extractParenthesis( string $type ): string
Extract content from parenthesis in $type

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$type string  

ORM\Dbal\Sqlite::hasCompositeKey

protected function hasCompositeKey( array $rawColumns ): boolean
Checks $rawColumns for a multiple primary key

Visibility: this method is protected.
Returns: this method returns boolean

Parameters
Parameter Type Description
$rawColumns array  

ORM\Dbal\Sqlite::insert

public function insert( $table, array $rows )

Visibility: this method is public.

Parameters
Parameter Type Description
$table    
$rows array  

ORM\Dbal\Sqlite::insertAndSync

public function insertAndSync( ORM\Entity $entities ): boolean
Insert $entities and update with default values from database

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns boolean
Throws: this method may throw \ORM\Exception\InvalidArgument

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Sqlite::insertAndSyncWithAutoInc

public function insertAndSyncWithAutoInc(
    ORM\Entity $entities
): integer|boolean
Insert $entities and sync with auto increment primary key

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns integer|boolean

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Sqlite::insertEntities

public function insertEntities( ORM\Entity $entities ): boolean
Insert $entities into database

The entities have to be from same type otherwise a InvalidArgument will be thrown.

Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Sqlite::normalizeColumnDefinition

protected function normalizeColumnDefinition(
    array $rawColumn, boolean $compositeKey = false
): array
Normalize a column definition

The column definition from “PRAGMA table_info(<table>)” is to special as useful. Here we normalize it to a more ANSI-SQL style.

Visibility: this method is protected.
Returns: this method returns array

Parameters
Parameter Type Description
$rawColumn array  
$compositeKey boolean  

ORM\Dbal\Sqlite::normalizeType

protected function normalizeType( string $type ): string
Normalize $type

The type returned by mysql is for example VARCHAR(20) - this function converts it to varchar

Visibility: this method is protected.
Returns: this method returns string

Parameters
Parameter Type Description
$type string  

ORM\Dbal\Sqlite::rollback

public function rollback(): boolean
Rollback the current transaction or save point

Visibility: this method is public.
Returns: this method returns boolean

ORM\Dbal\Sqlite::setOption

public function setOption( string $option, $value ): $this
Set $option to $value

Visibility: this method is public.
Returns: this method returns $this

Parameters
Parameter Type Description
$option string  
$value mixed  

ORM\Dbal\Sqlite::syncInserted

protected function syncInserted( ORM\Entity $entities )
Sync the $entities after insert

Visibility: this method is protected.

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Sqlite::syncInsertedWithAutoInc

protected function syncInsertedWithAutoInc( ORM\Entity $entities )
Synchronize inserted $entities

This method expects that the inserted $entities where the last inserted entities and using an auto incremented primary key.

Visibility: this method is protected.

Parameters
Parameter Type Description
$entities \ORM\Entity  

ORM\Dbal\Sqlite::update

public function update(
    string $table, array $where, array $updates, array $joins = array()
): integer
Update $table using $where to set $updates

Simple usage: update('table', ['id' => 23], ['name' => 'John Doe'])

For advanced queries with parenthesis, joins (if supported from your DBMS) etc. use QueryBuilder:

$em->query('table')
 ->where('birth_date', '>', EM::raw('DATE_SUB(NOW(), INTERVAL 18 YEARS)'))
 ->update(['teenager' => true]);

Visibility: this method is public.
Returns: this method returns integer
Response description: The number of affected rows

Parameters
Parameter Type Description
$table string The table to update
$where array An array of where conditions
$updates array An array of columns to update
$joins array For internal use from query builder only

ORM\Dbal\Sqlite::updateAutoincrement

protected function updateAutoincrement( ORM\Entity $entity, $value )
Update the autoincrement value

Visibility: this method is protected.

Parameters
Parameter Type Description
$entity \ORM\Entity  
$value integer | string  

ORM\Dbal\Table

Extends:

Table is basically an array of Columns

Properties

Visibility Name Type Description
protected $columns array<Column> The columns from this table

Methods

ORM\Dbal\Table::__construct

public function __construct( array<\ORM\Dbal\Column> $columns )
Table constructor.

Visibility: this method is public.

Parameters
Parameter Type Description
$columns array<Column>  

ORM\Dbal\Table::getColumn

public function getColumn( string $col ): ORM\Dbal\Column
Get the Column object for $col

Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Column

Parameters
Parameter Type Description
$col string  

ORM\Dbal\Table::validate

public function validate( string $col, $value ): boolean|ORM\Dbal\Error
Validate $value for column $col.

Returns an array with at least

Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Throws: this method may throw \ORM\Exception\UnknownColumn

Parameters
Parameter Type Description
$col string  
$value mixed  

ORM\Dbal\Type\Text

Extends: ORM\Dbal\Type\VarChar

Text data type

This is also the base type for any other data type

Properties

Visibility Name Type Description
protected $maxLength integer  
protected $type string  

ORM\Dbal\Type\Time

Extends: ORM\Dbal\Type\DateTime

Time data type

Properties

Visibility Name Type Description
protected $precision integer  
protected $regex string  

Methods

ORM\Dbal\Type\Time::__construct

public function __construct( integer $precision = null )
DateTime constructor

Visibility: this method is public.

Parameters
Parameter Type Description
$precision integer  

ORM\Dbal\Type\Time::factory

public static function factory(
    ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
Returns a new Type object

This method is only for types covered by mapping. Use fromDefinition instead for custom types.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns static

Parameters
Parameter Type Description
$dbal \ORM\Dbal\Dbal  
$columnDefinition array  

ORM\Dbal\Type\Time::fits

public static function fits( array $columnDefinition ): boolean
Check if this type fits to $columnDefinition

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$columnDefinition array  

ORM\Dbal\Type\Time::getPrecision

public function getPrecision(): integer

Visibility: this method is public.
Returns: this method returns integer

ORM\Dbal\Type\Time::validate

public function validate( $value ): boolean|ORM\Dbal\Error
Check if $value is valid for this type

Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error

Parameters
Parameter Type Description
$value mixed  

ORM\Dbal\Error\TooLong

Extends: ORM\Dbal\Error

TooLong Validation Error

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.

Constants

Name Value
ERROR_CODE 'TOO_LONG'

Properties

Visibility Name Type Description
protected $errorCode string  
protected $message string  

ORM\Dbal\Type

Implements: ORM\Dbal\TypeInterface

Base class for data types

Methods

ORM\Dbal\Type::factory

public static function factory(
    ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
Returns a new Type object

This method is only for types covered by mapping. Use fromDefinition instead for custom types.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns static

Parameters
Parameter Type Description
$dbal Dbal  
$columnDefinition array  

ORM\Dbal\Type::fits

public static function fits( array $columnDefinition ): boolean
Check if this type fits to $columnDefinition

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$columnDefinition array  

ORM\Dbal\TypeInterface

Interface TypeInterface

Methods

ORM\Dbal\TypeInterface::factory

public static function factory(
    ORM\Dbal\Dbal $dbal, array $columnDefinition
): ORM\Dbal\Type
Create Type class for given $dbal and $columnDefinition

Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Type

Parameters
Parameter Type Description
$dbal Dbal  
$columnDefinition array  

ORM\Dbal\TypeInterface::fits

public static function fits( array $columnDefinition ): boolean
Check if this type fits to $columnDefinition

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$columnDefinition array  

ORM\Dbal\TypeInterface::validate

public function validate( $value ): boolean|ORM\Dbal\Error
Check if $value is valid for this type

Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error

Parameters
Parameter Type Description
$value mixed  

ORM\Exception\UndefinedRelation

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Exception\UnknownColumn

Extends: ORM\Exception

Base exception for ORM

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Exception\UnsupportedDriver

Extends: ORM\Exception

Every ORM exception extends this class. So you can easily catch all exceptions from ORM.


ORM\Event\Updated

Extends: ORM\Event\UpdateEvent

Constants

Name Value
NAME 'updated'

Properties

Visibility Name Type Description
protected $data array  
protected $dirty array  
protected $entity ** \ ORM \ Entity**  
protected $stopped boolean  

ORM\Event\UpdateEvent

Extends: ORM\Event

Properties

Visibility Name Type Description
protected $data array  
protected $dirty array  
protected $entity ** \ ORM \ Entity**  
protected $stopped boolean  

Methods

ORM\Event\UpdateEvent::__construct

public function __construct( ORM\Entity $entity, array $dirty )

Visibility: this method is public.

Parameters
Parameter Type Description
$entity \ORM\Entity  
$dirty array  

ORM\Event\UpdateEvent::__get

public function __get( $name )

Visibility: this method is public.

Parameters
Parameter Type Description
$name    

ORM\Event\UpdateEvent::stop

public function stop()

Visibility: this method is public.


ORM\Event\Updating

Extends: ORM\Event\UpdateEvent

Constants

Name Value
NAME 'updating'

Properties

Visibility Name Type Description
protected $data array  
protected $dirty array  
protected $entity ** \ ORM \ Entity**  
protected $stopped boolean  

ORM\Dbal\Type\VarChar

Extends: ORM\Dbal\Type

String data type

With and without max / fixed length

Properties

Visibility Name Type Description
protected $maxLength integer  
protected $type string  

Methods

ORM\Dbal\Type\VarChar::__construct

public function __construct( integer $maxLength = null )
VarChar constructor

Visibility: this method is public.

Parameters
Parameter Type Description
$maxLength integer  

ORM\Dbal\Type\VarChar::factory

public static function factory(
    ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
Returns a new Type object

This method is only for types covered by mapping. Use fromDefinition instead for custom types.

Static: this method is static.
Visibility: this method is public.
Returns: this method returns static

Parameters
Parameter Type Description
$dbal \ORM\Dbal\Dbal  
$columnDefinition array  

ORM\Dbal\Type\VarChar::fits

public static function fits( array $columnDefinition ): boolean
Check if this type fits to $columnDefinition

Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean

Parameters
Parameter Type Description
$columnDefinition array  

ORM\Dbal\Type\VarChar::getMaxLength

public function getMaxLength(): integer

Visibility: this method is public.
Returns: this method returns integer

ORM\Dbal\Type\VarChar::validate

public function validate( $value ): boolean|ORM\Dbal\Error
Check if $value is valid for this type

Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error

Parameters
Parameter Type Description
$value mixed