just another orm...
View the Project on GitHub tflori/orm
Implements: ORM\ObserverInterface
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).
public function handle( ORM\Event $event ): boolean
Return false to stop event execution.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$event |
\ORM\Event |
Extends: ORM\Dbal\Type
Visibility | Name | Type | Description |
---|---|---|---|
protected | $dbal |
** \ ORM \ Dbal \ Dbal** |
public function __construct( ORM\Dbal\Dbal $dbal )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$dbal |
\ORM\Dbal\Dbal |
public static function factory(
ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
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
Parameter | Type | Description |
---|---|---|
$dbal |
\ORM\Dbal\Dbal | |
$columnDefinition |
array |
public static function fits( array $columnDefinition ): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$columnDefinition |
array |
protected function getBoolean( boolean $bool ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$bool |
boolean |
public function validate( $value ): boolean|ORM\Dbal\Error
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Parameter | Type | Description |
---|---|---|
$value |
mixed |
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 |
public function __construct(
ORM\Dbal\Dbal $dbal, string $class, integer $limit = 20
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$dbal |
Dbal\Dbal | |
$class |
string | |
$limit |
integer |
public function add( ORM\Entity $entities )
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidArgument
Parameter | Type | Description |
---|---|---|
$entities |
Entity |
protected function execute()
Visibility: this method is protected.
public function finish(): array<\ORM\Entity>
Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>
public function getLimit(): integer
Visibility: this method is public.
Returns: this method returns integer
public function limit( integer $limit ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$limit |
integer |
public function noAutoIncrement(): $this
Caution: If this is disabled updating could cause a IncompletePrimaryKey exception.
Visibility: this method is public.
Returns: this method returns $this
public function noUpdates(): $this
Visibility: this method is public.
Returns: this method returns $this
public function onSync( callable $callback = null ): $this
Provides an array of the just inserted entities in first argument.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$callback |
callable |
public function updateEntities(): $this
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
public function useAutoincrement(): $this
Caution: Your db access layer (DBAL) may not support this feature.
Visibility: this method is public.
Returns: this method returns $this
Implements: ORM\EntityFetcher\FilterInterface
Visibility | Name | Type | Description |
---|---|---|---|
protected | $filter |
public function __construct( callable $filter )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$filter |
callable |
public function apply( ORM\EntityFetcher $fetcher ): void
Visibility: this method is public.
Returns: this method returns void
Parameter | Type | Description |
---|---|---|
$fetcher |
\ORM\EntityFetcher |
Extends: ORM\Observer\AbstractObserver
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).
Visibility | Name | Type | Description |
---|---|---|---|
protected | $handlers |
public function handle( ORM\Event $event ): boolean
Return false to stop event execution.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$event |
\ORM\Event |
public function off( $event ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$event |
public function on( $event, callable $listener ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$event |
||
$listener |
callable |
Extends: ORM\Event
Name | Value |
---|---|
NAME | 'changed' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $attribute |
string | |
protected | $data |
array | |
protected | $entity |
** \ ORM \ Entity** | |
protected | $newValue |
mixed | |
protected | $oldValue |
mixed | |
protected | $stopped |
boolean |
public function __construct(
ORM\Entity $entity, $attribute, $oldValue, $newValue
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity | |
$attribute |
||
$oldValue |
||
$newValue |
public function __get( $name )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$name |
public function stop()
Visibility: this method is public.
Visibility | Name | Type | Description |
---|---|---|---|
protected | $columnDefinition |
array | |
protected | $dbal |
Dbal | |
protected | $hasDefault |
boolean | |
protected | $isNullable |
boolean | |
protected static | $registeredTypes |
array<string> | |
protected | $type |
TypeInterface |
public function __construct( ORM\Dbal\Dbal $dbal, array $columnDefinition )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$dbal |
Dbal | |
$columnDefinition |
array |
public function __get( string $name ): mixed
Visibility: this method is public.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$name |
string |
public function getDefault(): mixed
Visibility: this method is public.
Returns: this method returns mixed
public function getName(): string
Visibility: this method is public.
Returns: this method returns string
public function getNullable(): boolean
Visibility: this method is public.
Returns: this method returns boolean
protected static function getRegisteredType( array $columnDefinition ): string
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$columnDefinition |
array |
public function getType(): ORM\Dbal\Type
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Type
public function hasDefault(): boolean
Visibility: this method is public.
Returns: this method returns boolean
public function isNullable(): boolean
Visibility: this method is public.
Returns: this method returns boolean
public static function registerType( string $type )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$type |
string | The full qualified class name |
public function validate( $value ): boolean|ORM\Dbal\Error
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Parameter | Type | Description |
---|---|---|
$value |
mixed |
Extends: ORM\Dbal\Type
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)?' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $precision |
integer | |
protected | $regex |
string |
public function __construct(
integer $precision = null, boolean $dateOnly = false
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$precision |
integer | |
$dateOnly |
boolean |
public static function factory(
ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
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
Parameter | Type | Description |
---|---|---|
$dbal |
\ORM\Dbal\Dbal | |
$columnDefinition |
array |
public static function fits( array $columnDefinition ): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$columnDefinition |
array |
public function getPrecision(): integer
Visibility: this method is public.
Returns: this method returns integer
public function validate( $value ): boolean|ORM\Dbal\Error
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Parameter | Type | Description |
---|---|---|
$value |
mixed |
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 |
public function __construct(
ORM\EntityManager $entityManager, array $options = array()
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$entityManager |
\ORM\EntityManager | |
$options |
array |
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
Parameter | Type | Description |
---|---|---|
$entities |
array<\ORM\Entity> |
public function beginTransaction(): boolean
Visibility: this method is public.
Returns: this method returns boolean
protected function buildDeleteStatement( $table, array $where )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$table |
||
$where |
array |
protected function buildInsert( string $table, array $rows ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$table |
string | |
$rows |
array |
protected function buildSetClause( array $updates )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$updates |
array |
protected function buildUpdateStatement( $table, array $where, array $updates )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$table |
||
$where |
array | |
$updates |
array |
public function commit( boolean $all = false ): boolean
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
Parameter | Type | Description |
---|---|---|
$all |
boolean | Commit all opened transactions and savepoints |
public function delete( string $table, array $where ): integer
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
Parameter | Type | Description |
---|---|---|
$table |
string | The table where to delete rows |
$where |
array | An array of where conditions |
public function deleteEntity( ORM\Entity $entity ): boolean
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
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity |
public function describe(
string $table
): ORM\Dbal\Table|array<\ORM\Dbal\Column>
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
Parameter | Type | Description |
---|---|---|
$table |
string |
protected function escapeBoolean( boolean $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
boolean |
protected function escapeDateTime( DateTime $value ): mixed
Visibility: this method is protected.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$value |
\DateTime |
protected function escapeDouble( double $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
double |
public function escapeIdentifier( string $identifier ): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$identifier |
string | Identifier to quote |
protected function escapeInteger( integer $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
integer |
protected function escapeNULL(): string
Visibility: this method is protected.
Returns: this method returns string
protected function escapeString( string $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
string |
public function escapeValue( $value ): string
Visibility: this method is public.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotScalar
Parameter | Type | Description |
---|---|---|
$value |
mixed | The variable that should be returned in SQL syntax |
protected function extractParenthesis( string $type ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$type |
string |
public function insert( $table, array $rows )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$table |
||
$rows |
array |
public function insertAndSync( ORM\Entity $entities ): boolean
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
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function insertAndSyncWithAutoInc(
ORM\Entity $entities
): integer|boolean
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
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function insertEntities( ORM\Entity $entities ): boolean
The entities have to be from same type otherwise a InvalidArgument will be thrown.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
protected function normalizeType( string $type ): string
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
Parameter | Type | Description |
---|---|---|
$type |
string |
public function rollback(): boolean
Visibility: this method is public.
Returns: this method returns boolean
public function setOption( string $option, $value ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$option |
string | |
$value |
mixed |
protected function syncInserted( ORM\Entity $entities )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function update(
string $table, array $where, array $updates, array $joins = array()
): integer
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
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 |
protected function updateAutoincrement( ORM\Entity $entity, $value )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity | |
$value |
integer | string |
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 |
public function __construct(
string $type, string $name, string $user = null, string $pass = null,
string $host = null, string $port = null, array $attributes = array()
)
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.
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 |
public function getDsn(): string
Visibility: this method is public.
Returns: this method returns string
Extends: ORM\Event
Name | Value |
---|---|
NAME | 'deleted' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $data |
array | |
protected | $entity |
** \ ORM \ Entity** | |
protected | $stopped |
boolean |
Extends: ORM\Event
Name | Value |
---|---|
NAME | 'deleting' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $data |
array | |
protected | $entity |
** \ ORM \ Entity** | |
protected | $stopped |
boolean |
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:
Name | Value |
---|---|
OPT_RELATION_CLASS | 'class' |
OPT_RELATION_CARDINALITY | 'cardinality' |
OPT_RELATION_REFERENCE | 'reference' |
OPT_RELATION_OPPONENT | 'opponent' |
OPT_RELATION_TABLE | 'table' |
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. |
final public function __construct(
array<mixed> $data = array(),
ORM\EntityManager $entityManager = null, boolean $fromDatabase = false
)
It calls ::onInit() after initializing $data and $originalData.
Visibility: this method is public.
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 |
public function __get( string $attribute ): mixed|null
Visibility: this method is public.
Returns: this method returns mixed|null
Parameter | Type | Description |
---|---|---|
$attribute |
string |
See Also:
public function __isset( $attribute ): boolean
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$attribute |
public function __serialize()
Visibility: this method is public.
public function __set( string $attribute, $value )
Visibility: this method is public.
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.
Parameter | Type | Description |
---|---|---|
$data |
array |
public function addRelated(
string $relation, array<\ORM\Entity> $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.
Parameter | Type | Description |
---|---|---|
$relation |
string | |
$entities |
array<Entity> |
protected static function boot()
Static: this method is static.
Visibility: this method is protected.
public static function bootIfNotBooted()
Static: this method is static.
Visibility: this method is public.
protected static function bootTraits()
Static: this method is static.
Visibility: this method is protected.
public function delete(): $this
You might want to implement soft deletes by overriding this method.
Visibility: this method is public.
Returns: this method returns $this
public function deleteRelated(
string $relation, array<\ORM\Entity> $entities
)
This method is only for many-to-many relations.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$relation |
string | |
$entities |
array<Entity> |
public static function describe(): ORM\Dbal\Table|array<\ORM\Dbal\Column>
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Table|array<mixed,\ORM\Dbal\Column>
public static function detachObserver( ORM\Observer\AbstractObserver $observer )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$observer |
Observer\AbstractObserver |
See Also:
public static function disableValidator( boolean $disable = true )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$disable |
boolean |
public static function enableValidator( boolean $enable = true )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$enable |
boolean |
public function exists(): boolean
Visibility: this method is public.
Returns: this method returns boolean
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
Parameter | Type | Description |
---|---|---|
$relation |
string | The relation to fetch |
$getAll |
boolean |
public function fill(
array $data, boolean $ignoreUnknown = false, boolean $checkMissing = false
)
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
Parameter | Type | Description |
---|---|---|
$data |
array | |
$ignoreUnknown |
boolean | |
$checkMissing |
boolean |
protected function generatePrimaryKey()
This method should only be executed from save method.
Visibility: this method is protected.
public function getAttribute( string $attribute ): mixed|null
If there is a custom getter this method get called instead.
Visibility: this method is public.
Returns: this method returns mixed|null
Parameter | Type | Description |
---|---|---|
$attribute |
string | The variable to get |
See Also:
public static function getAttributeName( string $column ): string
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
Parameter | Type | Description |
---|---|---|
$column |
string |
public static function getColumnName( string $attribute ): string
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
Parameter | Type | Description |
---|---|---|
$attribute |
string |
public function getDirty(): array
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
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
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
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
public function getPrimaryKey(): array
Visibility: this method is public.
Returns: this method returns array
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey
public static function getPrimaryKeyVars(): array
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
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
Parameter | Type | Description |
---|---|---|
$relation |
string | |
$refresh |
boolean |
public static function getRelation( string $name ): ORM\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
Parameter | Type | Description |
---|---|---|
$name |
string |
public static function getTableName(): string
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
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
public function hasLoaded( string $relation ): boolean
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$relation |
string |
public function hasPrimaryKey(): boolean
Visibility: this method is public.
Returns: this method returns boolean
private function insertEntity( boolean $hasPrimaryKey ): ORM\Event\Inserted|null
Visibility: this method is private.
Returns: this method returns \ORM\Event\Inserted|null
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey
Parameter | Type | Description |
---|---|---|
$hasPrimaryKey |
boolean |
public static function isAutoIncremented(): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
public function isDirty( string $attribute = null ): boolean
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$attribute |
string | Check only this variable or all variables |
public function isValid(): boolean|array<\ORM\Dbal\Error>
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>
public static function isValidatorEnabled(): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
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
Parameter | Type | Description |
---|---|---|
$relation |
string |
public static function observeBy(
$observer = null
): ORM\Observer\CallbackObserver|null
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
Parameter | Type | Description |
---|---|---|
$observer |
Observer\AbstractObserver | null |
See Also:
public function onChange( string $attribute, $oldValue, $value )
Get called when something is changed with magic setter.
Visibility: this method is public.
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 |
public function onInit( boolean $new )
Get called when the entity get initialized.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$new |
boolean | Whether or not the entity is new or from database |
public function postPersist()
Get called after the entity got inserted in database.
Visibility: this method is public.
public function postUpdate()
Get called after the entity got updated in database.
Visibility: this method is public.
public function prePersist()
Get called before the entity get inserted in database.
Visibility: this method is public.
public function preUpdate()
Get called before the entity get updated in database.
Visibility: this method is public.
public static function query(): ORM\EntityFetcher
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\EntityFetcher
public static function registerGlobalFilter( $filter )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$filter |
string | EntityFetcher\FilterInterface | callable |
public function reset( string $attribute = null )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$attribute |
string | Reset only this variable or all variables |
public function resetRelated( null $relation = null )
Helpful to reduce the size of serializations of the object (for caching, or toArray method etc.)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$relation |
null |
public function save(): $this
Visibility: this method is public.
Returns: this method returns $this
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey
public function serialize(): string
Visibility: this method is public.
Returns: this method returns string
See Also:
public function setAttribute( string $attribute, $value ): $this
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
Parameter | Type | Description |
---|---|---|
$attribute |
string | The variable to change |
$value |
mixed | The value to store |
See Also:
public function setEntityManager( ORM\EntityManager $entityManager ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$entityManager |
EntityManager |
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.
Parameter | Type | Description |
---|---|---|
$namingSchemeColumn |
string |
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.
Parameter | Type | Description |
---|---|---|
$namingSchemeMethods |
string |
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.
Parameter | Type | Description |
---|---|---|
$namingSchemeTable |
string |
public function setRelated( string $relation, ORM\Entity $entity = null )
This method is only for the owner of a relation.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$relation |
string | |
$entity |
Entity |
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.
Parameter | Type | Description |
---|---|---|
$tableNameTemplate |
string |
public function toArray(
array $attributes = array(), boolean $includeRelations = true,
array $parents = array()
): array
Visibility: this method is public.
Returns: this method returns array
Parameter | Type | Description |
---|---|---|
$attributes |
array | |
$includeRelations |
boolean | |
$parents |
array | Prevent output containing toArray from parents |
protected static function toArrayPreventRecursion(
ORM\Entity $relatedObject, array $parents
)
Static: this method is static.
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$relatedObject |
Entity | |
$parents |
array |
public function unserialize( string $serialized )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$serialized |
string | The string representation of data |
See Also:
private function updateEntity(): ORM\Event\Updated|null
Visibility: this method is private.
Returns: this method returns \ORM\Event\Updated|null
public static function validate(
string $attribute, $value
): boolean|ORM\Dbal\Error
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Parameter | Type | Description |
---|---|---|
$attribute |
string | |
$value |
mixed |
public static function validateArray( array $data ): array
$data has to be an array of $attribute => $value
Static: this method is static.
Visibility: this method is public.
Returns: this method returns array
Parameter | Type | Description |
---|---|---|
$data |
array |
Extends: ORM\QueryBuilder\QueryBuilder
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:
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 |
public function __construct( ORM\EntityManager $entityManager, $class )
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.
Parameter | Type | Description |
---|---|---|
$entityManager |
EntityManager | EntityManager where to store the fetched entities |
$class |
Entity | string | Class to fetch |
public function all( integer $limit ): array<\ORM\Entity>
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>
Parameter | Type | Description |
---|---|---|
$limit |
integer | Maximum number of entities to fetch |
public function andParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function andWhere(
string $column, $operator = null, string $value = null
): $this
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
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) |
protected function applyFilters()
Visibility: this method is protected.
public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface
public function column(
string $column, array $args = array(), string $alias = ''
): $this
Optionally you can provide an expression with question marks as placeholders filled with $args.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression to fetch |
$args |
array | Arguments for expression |
$alias |
string | Alias for the column |
public function columns( array $columns = null ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$columns |
array |
protected function convertPlaceholders(
string $expression, $args, boolean $translateCols = true
): string
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
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 |
public function count(): integer
Visibility: this method is public.
Returns: this method returns integer
public function createRelatedJoin( $join, $relation ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$join |
||
$relation |
public function delete(): integer
Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows
public function filter( $filter ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$filter |
string | EntityFetcher\FilterInterface | callable |
public function fullJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
private function getDefaultOperator( $value ): string
Arrays use IN
by default - all others use =
Visibility: this method is private.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
mixed | The value to determine the operator |
public function getEntityManager(): ORM\EntityManager
Visibility: this method is public.
Returns: this method returns \ORM\EntityManager
public function getExpression(): string
Returns the complete expression inside this parenthesis.
Visibility: this method is public.
Returns: this method returns string
public static function getGlobalFilters( string $class ): array
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
Parameter | Type | Description |
---|---|---|
$class |
string |
public function getQuery(): string
Builds the statement from current where conditions, joins, columns and so on.
Visibility: this method is public.
Returns: this method returns string
protected function getStatement(): PDOStatement|boolean
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
protected function getTableAndAlias( string $class, string $alias = '' ): array
Visibility: this method is protected.
Returns: this method returns array
Response description: [$table, $alias]
Parameter | Type | Description |
---|---|---|
$class |
string | |
$alias |
string |
public function groupBy( string $column, array $args = array() ): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for groups |
$args |
array | Arguments for expression |
public function insert( array $rows ): integer
Visibility: this method is public.
Returns: this method returns integer
Response description: The number of inserted rows
Parameter | Type | Description |
---|---|---|
$rows |
array |
public function join(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function joinRelated( $relation ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$relation |
public function leftJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function leftJoinRelated( $relation ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$relation |
public function limit( integer $limit ): $this
Limits the amount of rows fetched from database.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$limit |
integer | The limit to set |
public function modifier( string $modifier ): $this
Add query modifiers such as SQL_CALC_FOUND_ROWS or DISTINCT.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$modifier |
string |
protected static function normalizeFilter(
$filter
): ORM\EntityFetcher\FilterInterface
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
Parameter | Type | Description |
---|---|---|
$filter |
string | EntityFetcher\FilterInterface | callable |
public function offset( integer $offset ): $this
Changes the offset (only with limit) where fetching starts in the query.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$offset |
integer | The offset to set |
public function one(): ORM\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
public function orderBy(
string $column, string $direction = self::DIRECTION_ASCENDING,
array $args = array()
): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for order |
$direction |
string | Direction (default: ASC ) |
$args |
array | Arguments for expression |
public function orParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function orWhere(
string $column, $operator = null, string $value = null
): $this
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
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) |
public function orWhereIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function orWhereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function parenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public static function registerGlobalFilter( $class, $filter )
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.
Parameter | Type | Description |
---|---|---|
$class |
||
$filter |
string | EntityFetcher\FilterInterface | callable |
public function reset(): $this
Visibility: this method is public.
Returns: this method returns $this
public function rightJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function setFetchMode(
integer $mode, $classNameObject = null, array $constructorArgs = null
): $this
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
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
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
Parameter | Type | Description |
---|---|---|
$query |
string | QueryBuilder\QueryBuilderInterface | Raw query string or a QueryBuilderInterface |
$args |
array | The arguments for placeholders |
private function toClassAndAlias( array $match ): array
Visibility: this method is private.
Returns: this method returns array
Response description: [$class, $alias]
Throws: this method may throw \ORM\Exception\NotJoined
Parameter | Type | Description |
---|---|---|
$match |
array |
protected function translateColumn( string $expression ): string
Visibility: this method is protected.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotJoined
Parameter | Type | Description |
---|---|---|
$expression |
string |
public function update( array $updates ): integer
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
Parameter | Type | Description |
---|---|---|
$updates |
array | An array of columns to update |
public function where( string $column, $operator = null, $value = null ): $this
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
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
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function whereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
private function wherePrefix( string $bool ): string
Visibility: this method is private.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$bool |
string | The prefix to use (‘AND’ or ‘OR’) |
public function with( string $relations ): $this
The relations are only loaded after you execute ->all()
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$relations |
string |
public function withoutFilter( string $filterClass ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$filterClass |
string |
Extends: ORM\EntityFetcher
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:
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 |
public function __construct(
callable $onClose, ORM\QueryBuilder\ParenthesisInterface $parent
)
Create a parenthesis inside another parenthesis or a query.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$onClose |
callable | Callable that gets executed when the parenthesis get closed |
$parent |
\ORM\QueryBuilder\ParenthesisInterface | Parent where createWhereCondition get executed |
public function all(): mixed|null
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
public function andParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function andWhere(
string $column, $operator = null, string $value = null
): $this
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
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) |
protected function applyFilters()
Visibility: this method is protected.
public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface
public function column(
string $column, array $args = array(), string $alias = ''
): $this
Optionally you can provide an expression with question marks as placeholders filled with $args.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression to fetch |
$args |
array | Arguments for expression |
$alias |
string | Alias for the column |
public function columns( array $columns = null ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$columns |
array |
protected function convertPlaceholders( string $expression, $args ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$expression |
string | Expression with placeholders |
$args |
array | mixed | Arguments for placeholders |
public function count(): integer
Visibility: this method is public.
Returns: this method returns integer
public function createRelatedJoin( $join, $relation ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$join |
||
$relation |
public function delete(): integer
Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows
public function filter( $filter ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$filter |
string | \ORM\EntityFetcher\FilterInterface | callable |
public function fullJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
private function getDefaultOperator( $value ): string
Arrays use IN
by default - all others use =
Visibility: this method is private.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
mixed | The value to determine the operator |
public function getEntityManager(): ORM\EntityManager
Visibility: this method is public.
Returns: this method returns \ORM\EntityManager
public function getExpression(): string
Returns the complete expression inside this parenthesis.
Visibility: this method is public.
Returns: this method returns string
public static function getGlobalFilters( string $class ): array
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
Parameter | Type | Description |
---|---|---|
$class |
string |
public function getQuery(): string
Builds the statement from current where conditions, joins, columns and so on.
Visibility: this method is public.
Returns: this method returns string
protected function getStatement(): PDOStatement|boolean
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
protected function getTableAndAlias( string $class, string $alias = '' ): array
Visibility: this method is protected.
Returns: this method returns array
Response description: [$table, $alias]
Parameter | Type | Description |
---|---|---|
$class |
string | |
$alias |
string |
public function groupBy( string $column, array $args = array() ): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for groups |
$args |
array | Arguments for expression |
public function insert( array $rows ): integer
Visibility: this method is public.
Returns: this method returns integer
Response description: The number of inserted rows
Parameter | Type | Description |
---|---|---|
$rows |
array |
public function join(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function joinRelated( $relation ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$relation |
public function leftJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function leftJoinRelated( $relation ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$relation |
public function limit( integer $limit ): $this
Limits the amount of rows fetched from database.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$limit |
integer | The limit to set |
public function modifier( string $modifier ): $this
Add query modifiers such as SQL_CALC_FOUND_ROWS or DISTINCT.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$modifier |
string |
protected static function normalizeFilter(
$filter
): ORM\EntityFetcher\FilterInterface
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
Parameter | Type | Description |
---|---|---|
$filter |
string | \ORM\EntityFetcher\FilterInterface | callable |
public function offset( integer $offset ): $this
Changes the offset (only with limit) where fetching starts in the query.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$offset |
integer | The offset to set |
public function one(): ORM\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
public function orderBy(
string $column, string $direction = self::DIRECTION_ASCENDING,
array $args = array()
): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for order |
$direction |
string | Direction (default: ASC ) |
$args |
array | Arguments for expression |
public function orParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function orWhere(
string $column, $operator = null, string $value = null
): $this
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
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) |
public function orWhereIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function orWhereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function parenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public static function registerGlobalFilter( $class, $filter )
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.
Parameter | Type | Description |
---|---|---|
$class |
||
$filter |
string | \ORM\EntityFetcher\FilterInterface | callable |
public function reset(): $this
Visibility: this method is public.
Returns: this method returns $this
public function rightJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function setFetchMode(
integer $mode, $classNameObject = null, array $constructorArgs = null
): $this
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
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
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
Parameter | Type | Description |
---|---|---|
$query |
string | \ORM\QueryBuilder\QueryBuilderInterface | Raw query string or a QueryBuilderInterface |
$args |
array | The arguments for placeholders |
private function toClassAndAlias( array $match ): array
Visibility: this method is private.
Returns: this method returns array
Response description: [$class, $alias]
Throws: this method may throw \ORM\Exception\NotJoined
Parameter | Type | Description |
---|---|---|
$match |
array |
protected function translateColumn( string $expression ): string
Visibility: this method is protected.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotJoined
Parameter | Type | Description |
---|---|---|
$expression |
string |
public function update( array $updates ): integer
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
Parameter | Type | Description |
---|---|---|
$updates |
array | An array of columns to update |
public function where( string $column, $operator = null, $value = null ): $this
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
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
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function whereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
private function wherePrefix( string $bool ): string
Visibility: this method is private.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$bool |
string | The prefix to use (‘AND’ or ‘OR’) |
public function with( string $relations ): $this
The relations are only loaded after you execute ->all()
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$relations |
string |
public function withoutFilter( string $filterClass ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$filterClass |
string |
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' |
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 |
public function __construct( array $options = array() )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$options |
array | Options for the new EntityManager |
public function beginTransaction(): boolean
Visibility: this method is public.
Returns: this method returns boolean
protected static function buildChecksum( array $primaryKey ): string
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$primaryKey |
array |
protected static function buildPrimaryKey( $class, array $primaryKey ): array
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns array
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey
Parameter | Type | Description |
---|---|---|
$class |
string | Entity | |
$primaryKey |
array |
public function commit( boolean $all = false ): boolean
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
Parameter | Type | Description |
---|---|---|
$all |
boolean | Commit all opened transactions and savepoints |
public function defineForNamespace( $nameSpace ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$nameSpace |
public function defineForParent( $class ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$class |
public function delete( ORM\Entity $entity ): boolean
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
Parameter | Type | Description |
---|---|---|
$entity |
Entity |
public function describe(
string $table
): array<\ORM\Dbal\Column>|ORM\Dbal\Table
Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Dbal\Column>|\ORM\Dbal\Table
Parameter | Type | Description |
---|---|---|
$table |
string |
public function detach( ORM\ObserverInterface $observer, $from = null ): boolean
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
Parameter | Type | Description |
---|---|---|
$observer |
ObserverInterface | |
$from |
string | null |
public function eagerLoad( string $relation, ORM\Entity $entities )
$relation can be nested by dividing them with a dot.
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\UndefinedRelation
Parameter | Type | Description |
---|---|---|
$relation |
string | |
$entities |
Entity |
public function escapeIdentifier( string $identifier ): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$identifier |
string | Identifier to quote |
public function escapeValue( $value ): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
mixed | The variable that should be returned in SQL syntax |
public function fetch(
string $class, $primaryKey = null
): ORM\Entity|ORM\EntityFetcher
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
Parameter | Type | Description |
---|---|---|
$class |
string | The entity class you want to fetch |
$primaryKey |
mixed | The primary key of the entity you want to fetch |
public function finishBulkInserts( $class ): array<\ORM\Entity>
Returns an array of entities added.
Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>
Parameter | Type | Description |
---|---|---|
$class |
public function fire( ORM\Event $event ): boolean
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$event |
Event |
public function getConnection(): PDO
Visibility: this method is public.
Returns: this method returns \PDO
Throws: this method may throw \ORM\Exception\NoConnection or \ORM\Exception\NoConnection
public function getDbal(): ORM\Dbal\Dbal
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Dbal
public static function getInstance( string $class = null ): ORM\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
Parameter | Type | Description |
---|---|---|
$class |
string |
private static function getInstanceByNameSpace( $class ): ORM\EntityManager
Static: this method is static.
Visibility: this method is private.
Returns: this method returns \ORM\EntityManager
Parameter | Type | Description |
---|---|---|
$class |
private static function getInstanceByParent( $class ): ORM\EntityManager
Static: this method is static.
Visibility: this method is private.
Returns: this method returns \ORM\EntityManager
Parameter | Type | Description |
---|---|---|
$class |
public function getNamer(): ORM\Namer
Visibility: this method is public.
Returns: this method returns \ORM\Namer
public function getOption( $option ): mixed
Visibility: this method is public.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$option |
public function has( $entity, $primaryKey = null ): boolean
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
Parameter | Type | Description |
---|---|---|
$entity |
Entity | string | |
$primaryKey |
mixed |
public function map(
ORM\Entity $entity, boolean $update = false, string $class = null
): ORM\Entity
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
Parameter | Type | Description |
---|---|---|
$entity |
Entity | |
$update |
boolean | Update the entity map |
$class |
string | Overwrite the class |
public function observe(
string $class, $observer = null
): ORM\Observer\CallbackObserver|null
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
Parameter | Type | Description |
---|---|---|
$class |
string | |
$observer |
ObserverInterface | null |
public function query(
string $table, string $alias = ''
): ORM\QueryBuilder\QueryBuilder
Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilder
Parameter | Type | Description |
---|---|---|
$table |
string | |
$alias |
string |
public static function raw( string $expression ): ORM\Dbal\Expression
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Expression
Parameter | Type | Description |
---|---|---|
$expression |
string |
public function rollback(): boolean
Visibility: this method is public.
Returns: this method returns boolean
public function setConnection( $connection )
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
Parameter | Type | Description |
---|---|---|
$connection |
mixed | A configuration for (or a) PDO instance |
public function setOption( string $option, $value ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$option |
string | One of OPT_* constants |
$value |
mixed |
public static function setResolver( callable $resolver )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$resolver |
callable |
public function sync( ORM\Entity $entity, boolean $reset = false ): boolean
If $reset is true it also calls reset() on $entity.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$entity |
Entity | |
$reset |
boolean | Reset entities current data |
public function useBulkInserts(
string $class, integer $limit = 20
): ORM\BulkInsert
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
Parameter | Type | Description |
---|---|---|
$class |
string | |
$limit |
integer | Maximum number of rows per insert |
Extends: ORM\EntityManager
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 |
public function __construct( array $options = array() )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$options |
array | Options for the new EntityManager |
public function addEntity( ORM\Entity $entity )
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.
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity |
public function addResult(
$class, ORM\Entity $entities
): ORM\Testing\EntityFetcherMock\Result|Mockery\MockInterface
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
Parameter | Type | Description |
---|---|---|
$class |
||
$entities |
\ORM\Entity |
public function beginTransaction(): boolean
Visibility: this method is public.
Returns: this method returns boolean
protected static function buildChecksum( array $primaryKey ): string
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$primaryKey |
array |
protected static function buildPrimaryKey( $class, array $primaryKey ): array
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns array
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey
Parameter | Type | Description |
---|---|---|
$class |
string | \ORM\Entity | |
$primaryKey |
array |
public function commit( boolean $all = false ): boolean
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
Parameter | Type | Description |
---|---|---|
$all |
boolean | Commit all opened transactions and savepoints |
public function defineForNamespace( $nameSpace ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$nameSpace |
public function defineForParent( $class ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$class |
public function delete( ORM\Entity $entity ): boolean
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
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity |
public function describe(
string $table
): array<\ORM\Dbal\Column>|ORM\Dbal\Table
Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Dbal\Column>|\ORM\Dbal\Table
Parameter | Type | Description |
---|---|---|
$table |
string |
public function detach( ORM\ObserverInterface $observer, $from = null ): boolean
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
Parameter | Type | Description |
---|---|---|
$observer |
\ORM\ObserverInterface | |
$from |
string | null |
public function eagerLoad( string $relation, ORM\Entity $entities )
$relation can be nested by dividing them with a dot.
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\UndefinedRelation
Parameter | Type | Description |
---|---|---|
$relation |
string | |
$entities |
\ORM\Entity |
public function escapeIdentifier( string $identifier ): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$identifier |
string | Identifier to quote |
public function escapeValue( $value ): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
mixed | The variable that should be returned in SQL syntax |
public function fetch(
string $class, $primaryKey = null
): ORM\Entity|ORM\EntityFetcher
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
Parameter | Type | Description |
---|---|---|
$class |
string | The entity class you want to fetch |
$primaryKey |
mixed | The primary key of the entity you want to fetch |
public function finishBulkInserts( $class ): array<\ORM\Entity>
Returns an array of entities added.
Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>
Parameter | Type | Description |
---|---|---|
$class |
public function fire( ORM\Event $event ): boolean
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$event |
\ORM\Event |
public function getConnection(): PDO
Visibility: this method is public.
Returns: this method returns \PDO
Throws: this method may throw \ORM\Exception\NoConnection or \ORM\Exception\NoConnection
public function getDbal(): ORM\Dbal\Dbal
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Dbal
public static function getInstance( string $class = null ): ORM\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
Parameter | Type | Description |
---|---|---|
$class |
string |
private static function getInstanceByNameSpace( $class ): ORM\EntityManager
Static: this method is static.
Visibility: this method is private.
Returns: this method returns \ORM\EntityManager
Parameter | Type | Description |
---|---|---|
$class |
private static function getInstanceByParent( $class ): ORM\EntityManager
Static: this method is static.
Visibility: this method is private.
Returns: this method returns \ORM\EntityManager
Parameter | Type | Description |
---|---|---|
$class |
public function getNamer(): ORM\Namer
Visibility: this method is public.
Returns: this method returns \ORM\Namer
public function getOption( $option ): mixed
Visibility: this method is public.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$option |
public function getResults( string $class, ORM\EntityFetcher $fetcher ): array
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
Parameter | Type | Description |
---|---|---|
$class |
string | |
$fetcher |
\ORM\EntityFetcher |
public function has( $entity, $primaryKey = null ): boolean
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
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity | string | |
$primaryKey |
mixed |
public function map(
ORM\Entity $entity, boolean $update = false, string $class = null
): ORM\Entity
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
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity | |
$update |
boolean | Update the entity map |
$class |
string | Overwrite the class |
public function observe(
string $class, $observer = null
): ORM\Observer\CallbackObserver|null
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
Parameter | Type | Description |
---|---|---|
$class |
string | |
$observer |
\ORM\ObserverInterface | null |
public function query(
string $table, string $alias = ''
): ORM\QueryBuilder\QueryBuilder
Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilder
Parameter | Type | Description |
---|---|---|
$table |
string | |
$alias |
string |
public static function raw( string $expression ): ORM\Dbal\Expression
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Expression
Parameter | Type | Description |
---|---|---|
$expression |
string |
public function retrieve( string $class, array $primaryKey ): ORM\Entity|null
Visibility: this method is public.
Returns: this method returns \ORM\Entity|null
Parameter | Type | Description |
---|---|---|
$class |
string | |
$primaryKey |
array |
public function rollback(): boolean
Visibility: this method is public.
Returns: this method returns boolean
public function setConnection( $connection )
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
Parameter | Type | Description |
---|---|---|
$connection |
mixed | A configuration for (or a) PDO instance |
public function setOption( string $option, $value ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$option |
string | One of OPT_* constants |
$value |
mixed |
public static function setResolver( callable $resolver )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$resolver |
callable |
public function sync( ORM\Entity $entity, boolean $reset = false ): boolean
If $reset is true it also calls reset() on $entity.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity | |
$reset |
boolean | Reset entities current data |
public function useBulkInserts(
string $class, integer $limit = 20
): ORM\BulkInsert
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
Parameter | Type | Description |
---|---|---|
$class |
string | |
$limit |
integer | Maximum number of rows per insert |
Extends: ORM\Dbal\Type
Visibility | Name | Type | Description |
---|---|---|---|
protected | $allowedValues |
array<string> |
public function __construct( array<string> $allowedValues )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$allowedValues |
array<string> |
public static function factory(
ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
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
Parameter | Type | Description |
---|---|---|
$dbal |
\ORM\Dbal\Dbal | |
$columnDefinition |
array |
public static function fits( array $columnDefinition ): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$columnDefinition |
array |
public function getAllowedValues(): array<string>
Visibility: this method is public.
Returns: this method returns array<mixed,string>
public function validate( $value ): boolean|ORM\Dbal\Error
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Parameter | Type | Description |
---|---|---|
$value |
mixed |
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Name | Value |
---|---|
ERROR_CODE | 'UNKNOWN' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $errorCode |
string | |
protected | $message |
string |
public function __construct(
array $params = array(), null $code = null, null $message = null,
ORM\Dbal\Error $previous = null
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$params |
array | |
$code |
null | |
$message |
null | |
$previous |
Error |
Name | Value |
---|---|
NAME | 'event' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $data |
array | |
protected | $entity |
Entity | |
protected | $stopped |
boolean |
public function __construct( ORM\Entity $entity )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$entity |
Entity |
public function __get( $name )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$name |
public function stop()
Visibility: this method is public.
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Visibility | Name | Type | Description |
---|---|---|---|
protected | $expression |
public function __construct( string $expression )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$expression |
string |
public function __toString()
Visibility: this method is public.
Extends: ORM\Event
Name | Value |
---|---|
NAME | 'fetched' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $data |
array | |
protected | $entity |
** \ ORM \ Entity** | |
protected | $rawData |
array | |
protected | $stopped |
boolean |
public function __construct( ORM\Entity $entity, array $rawData )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity | |
$rawData |
array |
public function __get( $name )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$name |
public function stop()
Visibility: this method is public.
public function apply( ORM\EntityFetcher $fetcher ): void
Visibility: this method is public.
Returns: this method returns void
Parameter | Type | Description |
---|---|---|
$fetcher |
\ORM\EntityFetcher |
Describes a class that generates primary keys in the protected method generatePrimaryKey()
public static function first( array $array, $default = null ): mixed
Returns $default if the array is empty.
Static: this method is static.
Visibility: this method is public.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$array |
array | |
$default |
mixed |
private static function getData( $item, $key )
Static: this method is static.
Visibility: this method is private.
Parameter | Type | Description |
---|---|---|
$item |
||
$key |
public static function getKey(
array $reference, ORM\Entity $entity, boolean $allowEmpty = true
): array|null
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
Parameter | Type | Description |
---|---|---|
$reference |
array | |
$entity |
Entity | |
$allowEmpty |
boolean |
public static function getUniqueKeys(
array $reference, ORM\Entity $entities
): array|false
Static: this method is static.
Visibility: this method is public.
Returns: this method returns array|false
Parameter | Type | Description |
---|---|---|
$reference |
array | |
$entities |
Entity |
See Also:
private static function getValueRetriever( $retriever )
Static: this method is static.
Visibility: this method is private.
Parameter | Type | Description |
---|---|---|
$retriever |
public static function groupBy( array $array, $retriever )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$array |
array | |
$retriever |
public static function keyBy( array $array, $retriever ): array|false
Static: this method is static.
Visibility: this method is public.
Returns: this method returns array|false
Parameter | Type | Description |
---|---|---|
$array |
array | |
$retriever |
public static function only( array $array, array $keys )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$array |
array | |
$keys |
array |
public static function pluck( array $array, $retriever )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$array |
array | |
$retriever |
public static function shortName( string $class ): string
Static: this method is static.
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$class |
string |
public static function traitUsesRecursive(
string $class, boolean $withParents = true
): array<string>
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>
Parameter | Type | Description |
---|---|---|
$class |
string | |
$withParents |
boolean |
public static function uniqueArrays( array<array> $array ): array
Static: this method is static.
Visibility: this method is public.
Returns: this method returns array
Parameter | Type | Description |
---|---|---|
$array |
array<array> |
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Event
Name | Value |
---|---|
NAME | 'inserted' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $data |
array | |
protected | $entity |
** \ ORM \ Entity** | |
protected | $stopped |
boolean |
Extends: ORM\Event
Name | Value |
---|---|
NAME | 'inserting' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $data |
array | |
protected | $entity |
** \ ORM \ Entity** | |
protected | $stopped |
boolean |
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Dbal\Error
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Name | Value |
---|---|
ERROR_CODE | 'INVALID_JSON' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $errorCode |
string | |
protected | $message |
string |
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Dbal\Type
public static function factory(
ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
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
Parameter | Type | Description |
---|---|---|
$dbal |
\ORM\Dbal\Dbal | |
$columnDefinition |
array |
public static function fits( array $columnDefinition ): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$columnDefinition |
array |
public function validate( $value ): boolean|ORM\Dbal\Error
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Parameter | Type | Description |
---|---|---|
$value |
mixed |
Extends: ORM\Relation
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 |
public function __construct(
string $class, array $reference, string $opponent, string $table,
$filters = array()
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$class |
string | |
$reference |
array | |
$opponent |
string | |
$table |
string | |
$filters |
array<\ORM\EntityFetcher\FilterInterface> | array<callable> |
public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$fetcher |
\ORM\EntityFetcher | |
$join |
||
$alias |
public function addRelated(
ORM\Entity $self, array $entities, ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey or \ORM\Exception\InvalidRelation or \ORM\Exception\IncompletePrimaryKey
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array | |
$entityManager |
\ORM\EntityManager |
protected function assignForeignObjects(
array $fkAttributes, array $keyAttributes, array $entities,
array $foreignObjects
)
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$fkAttributes |
array | |
$keyAttributes |
array | |
$entities |
array | |
$foreignObjects |
array |
protected function checkBoundTo( $parent, $name )
Visibility: this method is protected.
Throws: this method may throw \ORM\Exception
Parameter | Type | Description |
---|---|---|
$parent |
||
$name |
protected function createFetcher(
ORM\EntityManager $entityManager
): ORM\EntityFetcher
Visibility: this method is protected.
Returns: this method returns \ORM\EntityFetcher
Parameter | Type | Description |
---|---|---|
$entityManager |
\ORM\EntityManager |
public static function createRelation(
string $parent, string $name, array $relDef
): ORM\Relation
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration
Parameter | Type | Description |
---|---|---|
$parent |
string | |
$name |
string | |
$relDef |
array |
public function deleteRelated(
ORM\Entity $self, array $entities, ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\IncompletePrimaryKey or \ORM\Exception\InvalidRelation or \ORM\Exception\IncompletePrimaryKey
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array | |
$entityManager |
\ORM\EntityManager |
public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$em |
\ORM\EntityManager | |
$entities |
\ORM\Entity |
public function fetch(
ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Runs fetch on the EntityManager and returns its result.
Visibility: this method is public.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
public function fetchAll(
ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
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
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
protected static function fromAssoc( $parent, array $relDef )
Static: this method is static.
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$parent |
||
$relDef |
array |
public static function fromShort( $parent, array $short )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$parent |
||
$short |
array |
protected function getMappingData(
ORM\EntityManager $em, array<\ORM\Entity> $entities
): array
Visibility: this method is protected.
Returns: this method returns array
Parameter | Type | Description |
---|---|---|
$em |
\ORM\EntityManager | |
$entities |
array<\ORM\Entity> |
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
Parameter | Type | Description |
---|---|---|
$requiredType |
string |
public function getReference()
Visibility: this method is public.
public function getTable(): string
Visibility: this method is public.
Returns: this method returns string
public function setRelated( ORM\Entity $self, $entity = null )
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entity |
\ORM\Entity | null |
Extends: ORM\Relation\Owner
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 |
public function __construct( string $morphColumn, $morph, array $reference )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$morphColumn |
string | |
$morph |
string | array | |
$reference |
array |
public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$fetcher |
\ORM\EntityFetcher | |
$join |
||
$alias |
public function addRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array<\ORM\Entity> | |
$entityManager |
\ORM\EntityManager |
public function apply( ORM\EntityFetcher $fetcher, ORM\Entity $entity )
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.
Parameter | Type | Description |
---|---|---|
$fetcher |
\ORM\EntityFetcher | |
$entity |
\ORM\Entity |
public function applyJoin(
ORM\QueryBuilder\Parenthesis $join, string $yourAlias,
ORM\Relation\OneToMany $opponent
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$join |
\ORM\QueryBuilder\Parenthesis | |
$yourAlias |
string | |
$opponent |
OneToMany |
protected function assignForeignObjects(
array $fkAttributes, array $keyAttributes, array $entities,
array $foreignObjects
)
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$fkAttributes |
array | |
$keyAttributes |
array | |
$entities |
array | |
$foreignObjects |
array |
protected function checkBoundTo( $parent, $name )
Visibility: this method is protected.
Throws: this method may throw \ORM\Exception
Parameter | Type | Description |
---|---|---|
$parent |
||
$name |
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.
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$newType |
string |
public static function createRelation(
string $parent, string $name, array $relDef
): ORM\Relation
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration
Parameter | Type | Description |
---|---|---|
$parent |
string | |
$name |
string | |
$relDef |
array |
public function deleteRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array<\ORM\Entity> | |
$entityManager |
\ORM\EntityManager |
public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$em |
\ORM\EntityManager | |
$entities |
\ORM\Entity |
public function eagerLoadSelf(
ORM\EntityManager $em, ORM\Entity $foreignObjects
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$em |
\ORM\EntityManager | |
$foreignObjects |
\ORM\Entity |
public function fetch(
ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Runs fetch on the EntityManager and returns its result.
Visibility: this method is public.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
public function fetchAll(
ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
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
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
public static function fromAssoc( $parent, array $relDef )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$parent |
||
$relDef |
array |
public static function fromShort( $parent, array $short )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$parent |
||
$short |
array |
protected function getMorphedClass( string $type ): string
Visibility: this method is protected.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\InvalidType
Parameter | Type | Description |
---|---|---|
$type |
string |
protected function getMorphedReference( string $type ): array
Visibility: this method is protected.
Returns: this method returns array
Parameter | Type | Description |
---|---|---|
$type |
string |
public function getReference()
Visibility: this method is public.
protected function getType( $class ): integer|string
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
Parameter | Type | Description |
---|---|---|
$class |
\ORM\Entity | string |
protected function hasForeignKeysByType(): boolean
Visibility: this method is protected.
Returns: this method returns boolean
public function setRelated( ORM\Entity $self, ORM\Entity $entity = null )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entity |
\ORM\Entity |
Extends: ORM\Dbal\Dbal
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 |
public function __construct(
ORM\EntityManager $entityManager, array $options = array()
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$entityManager |
\ORM\EntityManager | |
$options |
array |
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
Parameter | Type | Description |
---|---|---|
$entities |
array<\ORM\Entity> |
public function beginTransaction(): boolean
Visibility: this method is public.
Returns: this method returns boolean
public function buildCompositeInExpression(
array $cols, array $values, boolean $inverse = false
): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$cols |
array | |
$values |
array | |
$inverse |
boolean | Whether it should be a IN or NOT IN operator |
protected function buildDeleteStatement( $table, array $where )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$table |
||
$where |
array |
protected function buildInsert( string $table, array $rows ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$table |
string | |
$rows |
array |
protected function buildSetClause( array $updates )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$updates |
array |
protected function buildTuples( array $values )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$values |
array |
protected function buildUpdateJoinStatement(
$table, array $where, array $updates, array $joins
)
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$table |
||
$where |
array | |
$updates |
array | |
$joins |
array |
protected function buildUpdateStatement( $table, array $where, array $updates )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$table |
||
$where |
array | |
$updates |
array |
public function commit( boolean $all = false ): boolean
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
Parameter | Type | Description |
---|---|---|
$all |
boolean | Commit all opened transactions and savepoints |
public function delete( string $table, array $where ): integer
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
Parameter | Type | Description |
---|---|---|
$table |
string | The table where to delete rows |
$where |
array | An array of where conditions |
public function deleteEntity( ORM\Entity $entity ): boolean
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
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity |
public function describe(
string $table
): ORM\Dbal\Table|array<\ORM\Dbal\Column>
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Table|array<mixed,\ORM\Dbal\Column>
Parameter | Type | Description |
---|---|---|
$table |
string |
protected function escapeBoolean( boolean $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
boolean |
protected function escapeDateTime( DateTime $value ): mixed
Visibility: this method is protected.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$value |
\DateTime |
protected function escapeDouble( double $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
double |
public function escapeIdentifier( string $identifier ): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$identifier |
string | Identifier to quote |
protected function escapeInteger( integer $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
integer |
protected function escapeNULL(): string
Visibility: this method is protected.
Returns: this method returns string
protected function escapeString( string $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
string |
public function escapeValue( $value ): string
Visibility: this method is public.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotScalar
Parameter | Type | Description |
---|---|---|
$value |
mixed | The variable that should be returned in SQL syntax |
protected function extractParenthesis( string $type ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$type |
string |
public function insert( $table, array $rows )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$table |
||
$rows |
array |
public function insertAndSync( ORM\Entity $entities ): boolean
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
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function insertAndSyncWithAutoInc(
ORM\Entity $entities
): integer|boolean
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
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function insertEntities( ORM\Entity $entities ): boolean
The entities have to be from same type otherwise a InvalidArgument will be thrown.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
protected function normalizeColumnDefinition( array $rawColumn ): array
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
Parameter | Type | Description |
---|---|---|
$rawColumn |
array |
protected function normalizeType( string $type ): string
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
Parameter | Type | Description |
---|---|---|
$type |
string |
public function rollback(): boolean
Visibility: this method is public.
Returns: this method returns boolean
public function setOption( string $option, $value ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$option |
string | |
$value |
mixed |
protected function syncInserted( ORM\Entity $entities )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
protected function syncInsertedWithAutoInc( ORM\Entity $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.
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function update(
string $table, array $where, array $updates, array $joins = array()
): integer
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
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 |
protected function updateAutoincrement( ORM\Entity $entity, $value )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity | |
$value |
integer | string |
Namer is an artificial word and is more a name giver. We just don’t wanted to write so much.
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> |
public function __construct( array $options = array() )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$options |
array |
protected function arrayToString(
array $array, string $accessor, string $glue
): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$array |
array | |
$accessor |
string | |
$glue |
string |
public function forceNamingScheme( string $name, string $namingScheme ): string
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
Parameter | Type | Description |
---|---|---|
$name |
string | The name of the var / column |
$namingScheme |
string | The naming scheme to use |
public function getAttributeName(
string $name, $prefix = null, string $namingScheme = null
): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$name |
string | |
$prefix |
||
$namingScheme |
string |
public function getColumnName(
string $class, string $attribute, string $prefix = null,
string $namingScheme = null
): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$class |
string | |
$attribute |
string | |
$prefix |
string | |
$namingScheme |
string |
public function getMethodName(
string $name, string $namingScheme = null
): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$name |
string | |
$namingScheme |
string |
public function getTableName(
string $class, string $template = null, string $namingScheme = null
): string
Visibility: this method is public.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\InvalidName
Parameter | Type | Description |
---|---|---|
$class |
string | |
$template |
string | |
$namingScheme |
string |
protected function getValue(
string $attribute, array $values, string $arrayGlue
): string
Visibility: this method is protected.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\InvalidConfiguration
Parameter | Type | Description |
---|---|---|
$attribute |
string | The key for $values |
$values |
array | |
$arrayGlue |
string |
public function setOption( string $option, $value ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$option |
string | |
$value |
mixed |
public function substitute(
string $template, array $values = array(), string $arrayGlue = ', '
): string
$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
Parameter | Type | Description |
---|---|---|
$template |
string | |
$values |
array | |
$arrayGlue |
string |
Extends: ORM\Dbal\Error
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Name | Value |
---|---|
ERROR_CODE | 'NO_BOOLEAN' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $errorCode |
string | |
protected | $message |
string |
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Dbal\Error
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Name | Value |
---|---|
ERROR_CODE | 'NO_DATETIME' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $errorCode |
string | |
protected | $message |
string |
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Dbal\Error
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Name | Value |
---|---|
ERROR_CODE | 'NO_NUMBER' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $errorCode |
string | |
protected | $message |
string |
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Dbal\Error
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Name | Value |
---|---|
ERROR_CODE | 'NO_STRING' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $errorCode |
string | |
protected | $message |
string |
Extends: ORM\Dbal\Error
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Name | Value |
---|---|
ERROR_CODE | 'NOT_ALLOWED' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $errorCode |
string | |
protected | $message |
string |
Extends: ORM\Dbal\Error
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Name | Value |
---|---|
ERROR_CODE | 'NO_TIME' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $errorCode |
string | |
protected | $message |
string |
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Dbal\Error
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Name | Value |
---|---|
ERROR_CODE | 'NOT_NULLABLE' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $errorCode |
string | |
protected | $message |
string |
public function __construct( ORM\Dbal\Column $column )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$column |
\ORM\Dbal\Column |
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Dbal\Error
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Name | Value |
---|---|
ERROR_CODE | 'NOT_VALID' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $errorCode |
string | |
protected | $message |
string |
public function __construct( ORM\Dbal\Column $column, ORM\Dbal\Error $previous )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$column |
\ORM\Dbal\Column | The column that got a not valid error |
$previous |
\ORM\Dbal\Error | The error from validate |
Extends: ORM\Dbal\Type
public static function factory(
ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
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
Parameter | Type | Description |
---|---|---|
$dbal |
\ORM\Dbal\Dbal | |
$columnDefinition |
array |
public static function fits( array $columnDefinition ): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$columnDefinition |
array |
public function validate( $value ): boolean|ORM\Dbal\Error
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Parameter | Type | Description |
---|---|---|
$value |
mixed |
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).
public function handle( ORM\Event $event ): boolean
Return false to stop event execution.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$event |
Event |
Extends: ORM\Relation
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 |
public function __construct(
string $class, string $opponent, $filters = array()
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$class |
string | |
$opponent |
string | |
$filters |
array<\ORM\EntityFetcher\FilterInterface> | array<callable> |
public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$fetcher |
\ORM\EntityFetcher | |
$join |
||
$alias |
public function addRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array<\ORM\Entity> | |
$entityManager |
\ORM\EntityManager |
protected function assignForeignObjects(
array $fkAttributes, array $keyAttributes, array $entities,
array $foreignObjects
)
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$fkAttributes |
array | |
$keyAttributes |
array | |
$entities |
array | |
$foreignObjects |
array |
protected function checkBoundTo( $parent, $name )
Visibility: this method is protected.
Throws: this method may throw \ORM\Exception
Parameter | Type | Description |
---|---|---|
$parent |
||
$name |
public static function createRelation(
string $parent, string $name, array $relDef
): ORM\Relation
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration
Parameter | Type | Description |
---|---|---|
$parent |
string | |
$name |
string | |
$relDef |
array |
protected static function createStaticFromAssoc( array $relDef ): static|null
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null
Parameter | Type | Description |
---|---|---|
$relDef |
array |
protected static function createStaticFromShort( array $short ): static|null
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null
Parameter | Type | Description |
---|---|---|
$short |
array |
public function deleteRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array<\ORM\Entity> | |
$entityManager |
\ORM\EntityManager |
public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$em |
\ORM\EntityManager | |
$entities |
\ORM\Entity |
public function fetch(
ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
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
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
public function fetchAll(
ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
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
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
protected static function fromAssoc( $parent, array $relDef )
Static: this method is static.
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$parent |
||
$relDef |
array |
public static function fromShort( $parent, array $short )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$parent |
||
$short |
array |
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
Parameter | Type | Description |
---|---|---|
$requiredType |
string |
public function setRelated( ORM\Entity $self, $entity = null )
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entity |
\ORM\Entity | null |
Extends: ORM\Relation\OneToMany
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 |
public function __construct(
string $class, string $opponent, $filters = array()
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$class |
string | |
$opponent |
string | |
$filters |
array<\ORM\EntityFetcher\FilterInterface> | array<callable> |
public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$fetcher |
\ORM\EntityFetcher | |
$join |
||
$alias |
public function addRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array<\ORM\Entity> | |
$entityManager |
\ORM\EntityManager |
protected function assignForeignObjects(
array $fkAttributes, array $keyAttributes, array $entities,
array $foreignObjects
)
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$fkAttributes |
array | |
$keyAttributes |
array | |
$entities |
array | |
$foreignObjects |
array |
protected function checkBoundTo( $parent, $name )
Visibility: this method is protected.
Throws: this method may throw \ORM\Exception
Parameter | Type | Description |
---|---|---|
$parent |
||
$name |
public static function createRelation(
string $parent, string $name, array $relDef
): ORM\Relation
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration
Parameter | Type | Description |
---|---|---|
$parent |
string | |
$name |
string | |
$relDef |
array |
protected static function createStaticFromAssoc( array $relDef ): static|null
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null
Parameter | Type | Description |
---|---|---|
$relDef |
array |
protected static function createStaticFromShort( array $short ): static|null
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null
Parameter | Type | Description |
---|---|---|
$short |
array |
public function deleteRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array<\ORM\Entity> | |
$entityManager |
\ORM\EntityManager |
public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$em |
\ORM\EntityManager | |
$entities |
\ORM\Entity |
public function fetch(
ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Runs fetch on the EntityManager and returns its result.
Visibility: this method is public.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
public function fetchAll(
ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
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
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
protected static function fromAssoc( $parent, array $relDef )
Static: this method is static.
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$parent |
||
$relDef |
array |
public static function fromShort( $parent, array $short )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$parent |
||
$short |
array |
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
Parameter | Type | Description |
---|---|---|
$requiredType |
string |
public function setRelated( ORM\Entity $self, $entity = null )
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entity |
\ORM\Entity | null |
Extends: ORM\Dbal\Dbal
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 |
Extends: ORM\Relation
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 |
public function __construct( string $class, array $reference )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$class |
string | |
$reference |
array |
public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$fetcher |
\ORM\EntityFetcher | |
$join |
||
$alias |
public function addRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array<\ORM\Entity> | |
$entityManager |
\ORM\EntityManager |
public function apply( ORM\EntityFetcher $fetcher, ORM\Entity $entity )
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.
Parameter | Type | Description |
---|---|---|
$fetcher |
\ORM\EntityFetcher | |
$entity |
\ORM\Entity |
public function applyJoin(
ORM\QueryBuilder\Parenthesis $join, string $yourAlias,
ORM\Relation\OneToMany $opponent
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$join |
\ORM\QueryBuilder\Parenthesis | |
$yourAlias |
string | |
$opponent |
OneToMany |
protected function assignForeignObjects(
array $fkAttributes, array $keyAttributes, array $entities,
array $foreignObjects
)
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$fkAttributes |
array | |
$keyAttributes |
array | |
$entities |
array | |
$foreignObjects |
array |
protected function checkBoundTo( $parent, $name )
Visibility: this method is protected.
Throws: this method may throw \ORM\Exception
Parameter | Type | Description |
---|---|---|
$parent |
||
$name |
public static function createRelation(
string $parent, string $name, array $relDef
): ORM\Relation
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration
Parameter | Type | Description |
---|---|---|
$parent |
string | |
$name |
string | |
$relDef |
array |
public function deleteRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array<\ORM\Entity> | |
$entityManager |
\ORM\EntityManager |
public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$em |
\ORM\EntityManager | |
$entities |
\ORM\Entity |
public function fetch(
ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Runs fetch on the EntityManager and returns its result.
Visibility: this method is public.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
public function fetchAll(
ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
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
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
protected static function fromAssoc( $parent, array $relDef )
Static: this method is static.
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$parent |
||
$relDef |
array |
public static function fromShort( $parent, array $short )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$parent |
||
$short |
array |
public function getReference()
Visibility: this method is public.
public function setRelated( ORM\Entity $self, ORM\Entity $entity = null )
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation or \ORM\Exception\IncompletePrimaryKey
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entity |
\ORM\Entity |
Extends: ORM\Relation\OneToMany
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 |
public function __construct(
string $class, string $opponent, $filters = array()
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$class |
string | |
$opponent |
string | |
$filters |
array<\ORM\EntityFetcher\FilterInterface> | array<callable> |
public function addJoin( ORM\EntityFetcher $fetcher, $join, $alias )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$fetcher |
\ORM\EntityFetcher | |
$join |
||
$alias |
public function addRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array<\ORM\Entity> | |
$entityManager |
\ORM\EntityManager |
protected function assignForeignObjects(
array $fkAttributes, array $keyAttributes, array $entities,
array $foreignObjects
)
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$fkAttributes |
array | |
$keyAttributes |
array | |
$entities |
array | |
$foreignObjects |
array |
public function buildTree( ORM\Entity $entities ): array<\ORM\Entity>
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>
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
protected function checkBoundTo( $parent, $name )
Visibility: this method is protected.
Throws: this method may throw \ORM\Exception
Parameter | Type | Description |
---|---|---|
$parent |
||
$name |
public static function createRelation(
string $parent, string $name, array $relDef
): ORM\Relation
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration
Parameter | Type | Description |
---|---|---|
$parent |
string | |
$name |
string | |
$relDef |
array |
protected static function createStaticFromAssoc( array $relDef ): static|null
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null
Parameter | Type | Description |
---|---|---|
$relDef |
array |
protected static function createStaticFromShort( array $short ): static|null
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns static|null
Parameter | Type | Description |
---|---|---|
$short |
array |
public function deleteRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entities |
array<\ORM\Entity> | |
$entityManager |
\ORM\EntityManager |
public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$em |
\ORM\EntityManager | |
$entities |
\ORM\Entity |
abstract public function fetch(
ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Runs fetch on the EntityManager and returns its result.
Visibility: this method is public.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
public function fetchAll(
ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
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
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entityManager |
\ORM\EntityManager |
protected static function fromAssoc( $parent, array $relDef )
Static: this method is static.
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$parent |
||
$relDef |
array |
public static function fromShort( $parent, array $short )
Static: this method is static.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$parent |
||
$short |
array |
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
Parameter | Type | Description |
---|---|---|
$requiredType |
string |
public function setRelated( ORM\Entity $self, $entity = null )
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
\ORM\Entity | |
$entity |
\ORM\Entity | null |
Implements: ORM\QueryBuilder\ParenthesisInterface
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 |
public function __construct(
callable $onClose, ORM\QueryBuilder\ParenthesisInterface $parent
)
Create a parenthesis inside another parenthesis or a query.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$onClose |
callable | Callable that gets executed when the parenthesis get closed |
$parent |
ParenthesisInterface | Parent where createWhereCondition get executed |
public function andParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function andWhere(
string $column, $operator = null, string $value = null
): $this
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
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) |
public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface
public function getExpression(): string
Returns the complete expression inside this parenthesis.
Visibility: this method is public.
Returns: this method returns string
public function orParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function orWhere(
string $column, $operator = null, string $value = null
): $this
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
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) |
public function orWhereIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function orWhereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function parenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function where( string $column, $operator = null, $value = null ): $this
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
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
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function whereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
private function wherePrefix( string $bool ): string
Visibility: this method is private.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$bool |
string | The prefix to use (‘AND’ or ‘OR’) |
public function andParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function andWhere(
string $column, $operator = '', string $value = ''
): $this
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
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) |
public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface
public function getExpression(): string
Returns the complete expression inside this parenthesis.
Visibility: this method is public.
Returns: this method returns string
public function orParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function orWhere(
string $column, $operator = '', string $value = ''
): $this
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
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) |
public function orWhereIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function orWhereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function parenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
See Also:
public function where( string $column, $operator = '', $value = '' ): $this
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
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
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function whereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
Extends: ORM\Dbal\Dbal
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 |
public function __construct(
ORM\EntityManager $entityManager, array $options = array()
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$entityManager |
\ORM\EntityManager | |
$options |
array |
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
Parameter | Type | Description |
---|---|---|
$entities |
array<\ORM\Entity> |
public function beginTransaction(): boolean
Visibility: this method is public.
Returns: this method returns boolean
protected function buildDeleteStatement( $table, array $where )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$table |
||
$where |
array |
protected function buildInsert( string $table, array $rows ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$table |
string | |
$rows |
array |
protected function buildSetClause( array $updates )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$updates |
array |
protected function buildUpdateFromStatement(
$table, array $where, array $updates, array $joins
)
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$table |
||
$where |
array | |
$updates |
array | |
$joins |
array |
protected function buildUpdateStatement( $table, array $where, array $updates )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$table |
||
$where |
array | |
$updates |
array |
public function commit( boolean $all = false ): boolean
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
Parameter | Type | Description |
---|---|---|
$all |
boolean | Commit all opened transactions and savepoints |
protected function convertJoin( $join )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$join |
public function delete( string $table, array $where ): integer
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
Parameter | Type | Description |
---|---|---|
$table |
string | The table where to delete rows |
$where |
array | An array of where conditions |
public function deleteEntity( ORM\Entity $entity ): boolean
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
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity |
public function describe(
$schemaTable
): ORM\Dbal\Table|array<\ORM\Dbal\Column>
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Table|array<mixed,\ORM\Dbal\Column>
Parameter | Type | Description |
---|---|---|
$schemaTable |
protected function escapeBoolean( boolean $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
boolean |
protected function escapeDateTime( DateTime $value ): mixed
Visibility: this method is protected.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$value |
\DateTime |
protected function escapeDouble( double $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
double |
public function escapeIdentifier( string $identifier ): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$identifier |
string | Identifier to quote |
protected function escapeInteger( integer $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
integer |
protected function escapeNULL(): string
Visibility: this method is protected.
Returns: this method returns string
protected function escapeString( string $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
string |
public function escapeValue( $value ): string
Visibility: this method is public.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotScalar
Parameter | Type | Description |
---|---|---|
$value |
mixed | The variable that should be returned in SQL syntax |
protected function extractParenthesis( string $type ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$type |
string |
public function insert( $table, array $rows )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$table |
||
$rows |
array |
public function insertAndSync( ORM\Entity $entities ): boolean
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
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function insertAndSyncWithAutoInc(
ORM\Entity $entities
): integer|boolean
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
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function insertEntities( ORM\Entity $entities ): boolean
The entities have to be from same type otherwise a InvalidArgument will be thrown.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
protected function normalizeType( string $type ): string
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
Parameter | Type | Description |
---|---|---|
$type |
string |
public function rollback(): boolean
Visibility: this method is public.
Returns: this method returns boolean
public function setOption( string $option, $value ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$option |
string | |
$value |
mixed |
protected function syncInserted( ORM\Entity $entities )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function update(
string $table, array $where, array $updates, array $joins = array()
): integer
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
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 |
protected function updateAutoincrement( ORM\Entity $entity, $value )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity | |
$value |
integer | string |
Extends: ORM\QueryBuilder\Parenthesis
Implements: ORM\QueryBuilder\QueryBuilderInterface
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:
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 |
public function __construct(
string $tableName, string $alias = '',
ORM\EntityManager $entityManager = null
)
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.
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 |
public function all(): mixed|null
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
public function andParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function andWhere(
string $column, $operator = null, string $value = null
): $this
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
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) |
public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface
public function column(
string $column, array $args = array(), string $alias = ''
): $this
Optionally you can provide an expression with question marks as placeholders filled with $args.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression to fetch |
$args |
array | Arguments for expression |
$alias |
string | Alias for the column |
public function columns( array $columns = null ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$columns |
array |
protected function convertPlaceholders( string $expression, $args ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$expression |
string | Expression with placeholders |
$args |
array | mixed | Arguments for placeholders |
public function delete(): integer
Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows
public function fullJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
private function getDefaultOperator( $value ): string
Arrays use IN
by default - all others use =
Visibility: this method is private.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
mixed | The value to determine the operator |
public function getEntityManager(): ORM\EntityManager
Visibility: this method is public.
Returns: this method returns \ORM\EntityManager
public function getExpression(): string
Returns the complete expression inside this parenthesis.
Visibility: this method is public.
Returns: this method returns string
public function getQuery(): string
Builds the statement from current where conditions, joins, columns and so on.
Visibility: this method is public.
Returns: this method returns string
protected function getStatement(): PDOStatement|boolean
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
public function groupBy( string $column, array $args = array() ): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for groups |
$args |
array | Arguments for expression |
public function insert( array $rows ): integer
Visibility: this method is public.
Returns: this method returns integer
Response description: The number of inserted rows
Parameter | Type | Description |
---|---|---|
$rows |
array |
public function join(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function leftJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function limit( integer $limit ): $this
Limits the amount of rows fetched from database.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$limit |
integer | The limit to set |
public function modifier( string $modifier ): $this
Add query modifiers such as SQL_CALC_FOUND_ROWS or DISTINCT.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$modifier |
string |
public function offset( integer $offset ): $this
Changes the offset (only with limit) where fetching starts in the query.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$offset |
integer | The offset to set |
public function one(): mixed|null
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
public function orderBy(
string $column, string $direction = self::DIRECTION_ASCENDING,
array $args = array()
): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for order |
$direction |
string | Direction (default: ASC ) |
$args |
array | Arguments for expression |
public function orParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function orWhere(
string $column, $operator = null, string $value = null
): $this
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
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) |
public function orWhereIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function orWhereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function parenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function reset(): $this
Visibility: this method is public.
Returns: this method returns $this
public function rightJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function setFetchMode(
integer $mode, $classNameObject = null, array $constructorArgs = null
): $this
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
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
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
Parameter | Type | Description |
---|---|---|
$updates |
array | An array of columns to update |
public function where( string $column, $operator = null, $value = null ): $this
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
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
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function whereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
private function wherePrefix( string $bool ): string
Visibility: this method is private.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$bool |
string | The prefix to use (‘AND’ or ‘OR’) |
Extends: ORM\QueryBuilder\ParenthesisInterface
Name | Value |
---|---|
DIRECTION_ASCENDING | 'ASC' |
DIRECTION_DESCENDING | 'DESC' |
public function andParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function andWhere(
string $column, $operator = '', string $value = ''
): $this
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
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) |
public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface
public function column(
string $column, array $args = array(), string $alias = ''
): $this
Optionally you can provide an expression with question marks as placeholders filled with $args.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression to fetch |
$args |
array | Arguments for expression |
$alias |
string | Alias for the column |
public function columns( $columns = null ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$columns |
array | null |
public function fullJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function getExpression(): string
Returns the complete expression inside this parenthesis.
Visibility: this method is public.
Returns: this method returns string
public function getQuery(): string
Builds the statement from current where conditions, joins, columns and so on.
Visibility: this method is public.
Returns: this method returns string
public function groupBy( string $column, array $args = array() ): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for groups |
$args |
array | Arguments for expression |
public function join(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function leftJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function limit( integer $limit ): $this
Limits the amount of rows fetched from database.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$limit |
integer | The limit to set |
public function modifier( string $modifier ): $this
Add query modifiers such as SQL_CALC_FOUND_ROWS or DISTINCT.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$modifier |
string |
public function offset( integer $offset ): $this
Changes the offset (only with limit) where fetching starts in the query.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$offset |
integer | The offset to set |
public function orderBy(
string $column, string $direction = self::DIRECTION_ASCENDING,
array $args = array()
): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for order |
$direction |
string | Direction (default: ASC ) |
$args |
array | Arguments for expression |
public function orParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function orWhere(
string $column, $operator = '', string $value = ''
): $this
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
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) |
public function orWhereIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function orWhereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function parenthesis(): $this
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
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
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 |
public function where( string $column, $operator = '', $value = '' ): $this
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
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
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function whereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
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' |
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 |
public function addRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
Entity | |
$entities |
array<Entity> | |
$entityManager |
EntityManager |
protected function assignForeignObjects(
array $fkAttributes, array $keyAttributes, array $entities,
array $foreignObjects
)
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$fkAttributes |
array | |
$keyAttributes |
array | |
$entities |
array | |
$foreignObjects |
array |
protected function checkBoundTo( $parent, $name )
Visibility: this method is protected.
Throws: this method may throw \ORM\Exception
Parameter | Type | Description |
---|---|---|
$parent |
||
$name |
public static function createRelation(
string $parent, string $name, array $relDef
): ORM\Relation
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Relation
Throws: this method may throw \ORM\Exception\InvalidConfiguration
Parameter | Type | Description |
---|---|---|
$parent |
string | |
$name |
string | |
$relDef |
array |
public function deleteRelated(
ORM\Entity $self, array<\ORM\Entity> $entities,
ORM\EntityManager $entityManager
)
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
Entity | |
$entities |
array<Entity> | |
$entityManager |
EntityManager |
public function eagerLoad( ORM\EntityManager $em, ORM\Entity $entities )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$em |
EntityManager | |
$entities |
Entity |
abstract public function fetch(
ORM\Entity $self, ORM\EntityManager $entityManager
): mixed
Runs fetch on the EntityManager and returns its result.
Visibility: this method is public.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$self |
Entity | |
$entityManager |
EntityManager |
public function fetchAll(
ORM\Entity $self, ORM\EntityManager $entityManager
): array<\ORM\Entity>|ORM\Entity
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
Parameter | Type | Description |
---|---|---|
$self |
Entity | |
$entityManager |
EntityManager |
public function setRelated( ORM\Entity $self, $entity = null )
Visibility: this method is public.
Throws: this method may throw \ORM\Exception\InvalidRelation
Parameter | Type | Description |
---|---|---|
$self |
Entity | |
$entity |
Entity | null |
Extends: ORM\EntityFetcher
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:
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 |
public function __construct(
callable $onClose, ORM\QueryBuilder\ParenthesisInterface $parent
)
Create a parenthesis inside another parenthesis or a query.
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$onClose |
callable | Callable that gets executed when the parenthesis get closed |
$parent |
\ORM\QueryBuilder\ParenthesisInterface | Parent where createWhereCondition get executed |
public function addEntities( array<\ORM\Entity> $entities ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$entities |
array<\ORM\Entity> |
public function all(): mixed|null
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
public function andParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function andWhere(
string $column, $operator = null, string $value = null
): $this
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
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) |
protected function applyFilters()
Visibility: this method is protected.
public function close(): ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface
Visibility: this method is public.
Returns: this method returns \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface
public function column(
string $column, array $args = array(), string $alias = ''
): $this
Optionally you can provide an expression with question marks as placeholders filled with $args.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression to fetch |
$args |
array | Arguments for expression |
$alias |
string | Alias for the column |
public function columns( array $columns = null ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$columns |
array |
public function compare( ORM\EntityFetcher $fetcher ): integer
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
Parameter | Type | Description |
---|---|---|
$fetcher |
\ORM\EntityFetcher |
protected function convertPlaceholders( string $expression, $args ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$expression |
string | Expression with placeholders |
$args |
array | mixed | Arguments for placeholders |
public function count(): integer
Visibility: this method is public.
Returns: this method returns integer
public function createRelatedJoin( $join, $relation ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$join |
||
$relation |
public function delete(): integer
Visibility: this method is public.
Returns: this method returns integer
Response description: The number of deleted rows
public function filter( $filter ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$filter |
string | \ORM\EntityFetcher\FilterInterface | callable |
public function fullJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
private function getDefaultOperator( $value ): string
Arrays use IN
by default - all others use =
Visibility: this method is private.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
mixed | The value to determine the operator |
public function getEntities(): array<\ORM\Entity>
Visibility: this method is public.
Returns: this method returns array<mixed,\ORM\Entity>
public function getEntityManager(): ORM\EntityManager
Visibility: this method is public.
Returns: this method returns \ORM\EntityManager
public function getExpression(): string
Returns the complete expression inside this parenthesis.
Visibility: this method is public.
Returns: this method returns string
public static function getGlobalFilters( string $class ): array
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
Parameter | Type | Description |
---|---|---|
$class |
string |
public function getQuery(): string
Builds the statement from current where conditions, joins, columns and so on.
Visibility: this method is public.
Returns: this method returns string
protected function getStatement(): PDOStatement|boolean
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
protected function getTableAndAlias( string $class, string $alias = '' ): array
Visibility: this method is protected.
Returns: this method returns array
Response description: [$table, $alias]
Parameter | Type | Description |
---|---|---|
$class |
string | |
$alias |
string |
public function groupBy( string $column, array $args = array() ): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for groups |
$args |
array | Arguments for expression |
public function insert( array $rows ): integer
Visibility: this method is public.
Returns: this method returns integer
Response description: The number of inserted rows
Parameter | Type | Description |
---|---|---|
$rows |
array |
public function join(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function joinRelated( $relation ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$relation |
public function leftJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function leftJoinRelated( $relation ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$relation |
public function limit( integer $limit ): $this
Limits the amount of rows fetched from database.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$limit |
integer | The limit to set |
public function matches( string $expression ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$expression |
string |
public function modifier( string $modifier ): $this
Add query modifiers such as SQL_CALC_FOUND_ROWS or DISTINCT.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$modifier |
string |
protected static function normalizeFilter(
$filter
): ORM\EntityFetcher\FilterInterface
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
Parameter | Type | Description |
---|---|---|
$filter |
string | \ORM\EntityFetcher\FilterInterface | callable |
public function offset( integer $offset ): $this
Changes the offset (only with limit) where fetching starts in the query.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$offset |
integer | The offset to set |
public function one(): mixed|null
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
public function orderBy(
string $column, string $direction = self::DIRECTION_ASCENDING,
array $args = array()
): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for order |
$direction |
string | Direction (default: ASC ) |
$args |
array | Arguments for expression |
public function orParenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public function orWhere(
string $column, $operator = null, string $value = null
): $this
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
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) |
public function orWhereIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function orWhereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function parenthesis(): $this
Visibility: this method is public.
Returns: this method returns $this
public static function registerGlobalFilter( $class, $filter )
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.
Parameter | Type | Description |
---|---|---|
$class |
||
$filter |
string | \ORM\EntityFetcher\FilterInterface | callable |
public function reset(): $this
Visibility: this method is public.
Returns: this method returns $this
public function rightJoin(
string $tableName, $expression = '', string $alias = '',
array $args = array()
): $this|ORM\QueryBuilder\ParenthesisInterface
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
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 |
public function setFetchMode(
integer $mode, $classNameObject = null, array $constructorArgs = null
): $this
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
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
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
Parameter | Type | Description |
---|---|---|
$query |
string | \ORM\QueryBuilder\QueryBuilderInterface | Raw query string or a QueryBuilderInterface |
$args |
array | The arguments for placeholders |
private function toClassAndAlias( array $match ): array
Visibility: this method is private.
Returns: this method returns array
Response description: [$class, $alias]
Throws: this method may throw \ORM\Exception\NotJoined
Parameter | Type | Description |
---|---|---|
$match |
array |
protected function translateColumn( string $expression ): string
Visibility: this method is protected.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotJoined
Parameter | Type | Description |
---|---|---|
$expression |
string |
public function update( array $updates ): integer
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
Parameter | Type | Description |
---|---|---|
$updates |
array | An array of columns to update |
public function where( string $column, $operator = null, $value = null ): $this
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
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
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
public function whereNotIn( $column, array $values ): $this
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
Parameter | Type | Description |
---|---|---|
$column |
string | array | |
$values |
array |
private function wherePrefix( string $bool ): string
Visibility: this method is private.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$bool |
string | The prefix to use (‘AND’ or ‘OR’) |
public function with( string $relations ): $this
The relations are only loaded after you execute ->all()
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$relations |
string |
public function withoutFilter( string $filterClass ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$filterClass |
string |
Name | Value |
---|---|
RANDOM_KEY_MIN | 1000000000 |
RANDOM_KEY_MAX | 1000999999 |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $em |
** \ ORM \ EntityManager** | |
protected | $primaryKeyMap |
array< \ ORM \ Entity[]> | |
protected | $results |
array<Result[]> |
public function __construct( ORM\EntityManager $em )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$em |
\ORM\EntityManager |
public function addEntity( ORM\Entity $entity )
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.
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity |
public function addResult(
$class, ORM\Entity $entities
): ORM\Testing\EntityFetcherMock\Result|Mockery\MockInterface
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
Parameter | Type | Description |
---|---|---|
$class |
||
$entities |
\ORM\Entity |
protected static function buildChecksum( array $primaryKey ): string
Static: this method is static.
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$primaryKey |
array |
public static function completePrimaryKeys(
ORM\Entity $entities
): array<\ORM\Entity>
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>
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function getResults( string $class, ORM\EntityFetcher $fetcher ): array
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
Parameter | Type | Description |
---|---|---|
$class |
string | |
$fetcher |
\ORM\EntityFetcher |
public function retrieve( string $class, array $primaryKey ): ORM\Entity|null
Visibility: this method is public.
Returns: this method returns \ORM\Entity|null
Parameter | Type | Description |
---|---|---|
$class |
string | |
$primaryKey |
array |
Extends: ORM\Event
Name | Value |
---|---|
NAME | 'saved' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $data |
array | |
protected | $entity |
** \ ORM \ Entity** | |
protected | $originalEvent |
** \ ORM \ Event** | |
protected | $stopped |
boolean |
public function __construct( ORM\Event $originalEvent )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$originalEvent |
\ORM\Event |
public function __get( $name )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$name |
public function stop()
Visibility: this method is public.
Extends: ORM\Event
Name | Value |
---|---|
NAME | 'saving' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $data |
array | |
protected | $entity |
** \ ORM \ Entity** | |
protected | $stopped |
boolean |
Extends: ORM\Dbal\Type\Enum
Visibility | Name | Type | Description |
---|---|---|---|
protected | $allowedValues |
array<string> | |
protected | $type |
public function __construct( array<string> $allowedValues )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$allowedValues |
array<string> |
public static function factory(
ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
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
Parameter | Type | Description |
---|---|---|
$dbal |
\ORM\Dbal\Dbal | |
$columnDefinition |
array |
public static function fits( array $columnDefinition ): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$columnDefinition |
array |
public function getAllowedValues(): array<string>
Visibility: this method is public.
Returns: this method returns array<mixed,string>
public function validate( $value ): boolean|ORM\Dbal\Error
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Parameter | Type | Description |
---|---|---|
$value |
mixed |
Extends: ORM\Dbal\Dbal
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 |
public function __construct(
ORM\EntityManager $entityManager, array $options = array()
)
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$entityManager |
\ORM\EntityManager | |
$options |
array |
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
Parameter | Type | Description |
---|---|---|
$entities |
array<\ORM\Entity> |
public function beginTransaction(): boolean
Visibility: this method is public.
Returns: this method returns boolean
protected function buildDeleteStatement( $table, array $where )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$table |
||
$where |
array |
protected function buildInsert( string $table, array $rows ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$table |
string | |
$rows |
array |
protected function buildSetClause( array $updates )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$updates |
array |
protected function buildUpdateFromStatement(
$table, array $where, array $updates, array $joins
)
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$table |
||
$where |
array | |
$updates |
array | |
$joins |
array |
protected function buildUpdateStatement( $table, array $where, array $updates )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$table |
||
$where |
array | |
$updates |
array |
public function commit( boolean $all = false ): boolean
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
Parameter | Type | Description |
---|---|---|
$all |
boolean | Commit all opened transactions and savepoints |
protected function convertJoin( $join )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$join |
public function delete( string $table, array $where ): integer
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
Parameter | Type | Description |
---|---|---|
$table |
string | The table where to delete rows |
$where |
array | An array of where conditions |
public function deleteEntity( ORM\Entity $entity ): boolean
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
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity |
public function describe(
$schemaTable
): ORM\Dbal\Table|array<\ORM\Dbal\Column>
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Table|array<mixed,\ORM\Dbal\Column>
Parameter | Type | Description |
---|---|---|
$schemaTable |
protected function escapeBoolean( boolean $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
boolean |
protected function escapeDateTime( DateTime $value ): mixed
Visibility: this method is protected.
Returns: this method returns mixed
Parameter | Type | Description |
---|---|---|
$value |
\DateTime |
protected function escapeDouble( double $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
double |
public function escapeIdentifier( string $identifier ): string
Visibility: this method is public.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$identifier |
string | Identifier to quote |
protected function escapeInteger( integer $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
integer |
protected function escapeNULL(): string
Visibility: this method is protected.
Returns: this method returns string
protected function escapeString( string $value ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$value |
string |
public function escapeValue( $value ): string
Visibility: this method is public.
Returns: this method returns string
Throws: this method may throw \ORM\Exception\NotScalar
Parameter | Type | Description |
---|---|---|
$value |
mixed | The variable that should be returned in SQL syntax |
protected function extractParenthesis( string $type ): string
Visibility: this method is protected.
Returns: this method returns string
Parameter | Type | Description |
---|---|---|
$type |
string |
protected function hasCompositeKey( array $rawColumns ): boolean
Visibility: this method is protected.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$rawColumns |
array |
public function insert( $table, array $rows )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$table |
||
$rows |
array |
public function insertAndSync( ORM\Entity $entities ): boolean
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
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function insertAndSyncWithAutoInc(
ORM\Entity $entities
): integer|boolean
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
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function insertEntities( ORM\Entity $entities ): boolean
The entities have to be from same type otherwise a InvalidArgument will be thrown.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
protected function normalizeColumnDefinition(
array $rawColumn, boolean $compositeKey = false
): array
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
Parameter | Type | Description |
---|---|---|
$rawColumn |
array | |
$compositeKey |
boolean |
protected function normalizeType( string $type ): string
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
Parameter | Type | Description |
---|---|---|
$type |
string |
public function rollback(): boolean
Visibility: this method is public.
Returns: this method returns boolean
public function setOption( string $option, $value ): $this
Visibility: this method is public.
Returns: this method returns $this
Parameter | Type | Description |
---|---|---|
$option |
string | |
$value |
mixed |
protected function syncInserted( ORM\Entity $entities )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
protected function syncInsertedWithAutoInc( ORM\Entity $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.
Parameter | Type | Description |
---|---|---|
$entities |
\ORM\Entity |
public function update(
string $table, array $where, array $updates, array $joins = array()
): integer
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
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 |
protected function updateAutoincrement( ORM\Entity $entity, $value )
Visibility: this method is protected.
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity | |
$value |
integer | string |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $columns |
array<Column> | The columns from this table |
public function __construct( array<\ORM\Dbal\Column> $columns )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$columns |
array<Column> |
public function getColumn( string $col ): ORM\Dbal\Column
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Column
Parameter | Type | Description |
---|---|---|
$col |
string |
public function validate( string $col, $value ): boolean|ORM\Dbal\Error
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
Parameter | Type | Description |
---|---|---|
$col |
string | |
$value |
mixed |
Extends: ORM\Dbal\Type\VarChar
This is also the base type for any other data type
Visibility | Name | Type | Description |
---|---|---|---|
protected | $maxLength |
integer | |
protected | $type |
string |
Extends: ORM\Dbal\Type\DateTime
Visibility | Name | Type | Description |
---|---|---|---|
protected | $precision |
integer | |
protected | $regex |
string |
public function __construct( integer $precision = null )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$precision |
integer |
public static function factory(
ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
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
Parameter | Type | Description |
---|---|---|
$dbal |
\ORM\Dbal\Dbal | |
$columnDefinition |
array |
public static function fits( array $columnDefinition ): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$columnDefinition |
array |
public function getPrecision(): integer
Visibility: this method is public.
Returns: this method returns integer
public function validate( $value ): boolean|ORM\Dbal\Error
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Parameter | Type | Description |
---|---|---|
$value |
mixed |
Extends: ORM\Dbal\Error
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Name | Value |
---|---|
ERROR_CODE | 'TOO_LONG' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $errorCode |
string | |
protected | $message |
string |
Implements: ORM\Dbal\TypeInterface
public static function factory(
ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
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
Parameter | Type | Description |
---|---|---|
$dbal |
Dbal | |
$columnDefinition |
array |
public static function fits( array $columnDefinition ): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$columnDefinition |
array |
public static function factory(
ORM\Dbal\Dbal $dbal, array $columnDefinition
): ORM\Dbal\Type
Static: this method is static.
Visibility: this method is public.
Returns: this method returns \ORM\Dbal\Type
Parameter | Type | Description |
---|---|---|
$dbal |
Dbal | |
$columnDefinition |
array |
public static function fits( array $columnDefinition ): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$columnDefinition |
array |
public function validate( $value ): boolean|ORM\Dbal\Error
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Parameter | Type | Description |
---|---|---|
$value |
mixed |
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Exception
Every ORM exception extends this class. So you can easily catch all exceptions from ORM.
Extends: ORM\Event\UpdateEvent
Name | Value |
---|---|
NAME | 'updated' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $data |
array | |
protected | $dirty |
array | |
protected | $entity |
** \ ORM \ Entity** | |
protected | $stopped |
boolean |
Extends: ORM\Event
Visibility | Name | Type | Description |
---|---|---|---|
protected | $data |
array | |
protected | $dirty |
array | |
protected | $entity |
** \ ORM \ Entity** | |
protected | $stopped |
boolean |
public function __construct( ORM\Entity $entity, array $dirty )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$entity |
\ORM\Entity | |
$dirty |
array |
public function __get( $name )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$name |
public function stop()
Visibility: this method is public.
Extends: ORM\Event\UpdateEvent
Name | Value |
---|---|
NAME | 'updating' |
Visibility | Name | Type | Description |
---|---|---|---|
protected | $data |
array | |
protected | $dirty |
array | |
protected | $entity |
** \ ORM \ Entity** | |
protected | $stopped |
boolean |
Extends: ORM\Dbal\Type
With and without max / fixed length
Visibility | Name | Type | Description |
---|---|---|---|
protected | $maxLength |
integer | |
protected | $type |
string |
public function __construct( integer $maxLength = null )
Visibility: this method is public.
Parameter | Type | Description |
---|---|---|
$maxLength |
integer |
public static function factory(
ORM\Dbal\Dbal $dbal, array $columnDefinition
): static
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
Parameter | Type | Description |
---|---|---|
$dbal |
\ORM\Dbal\Dbal | |
$columnDefinition |
array |
public static function fits( array $columnDefinition ): boolean
Static: this method is static.
Visibility: this method is public.
Returns: this method returns boolean
Parameter | Type | Description |
---|---|---|
$columnDefinition |
array |
public function getMaxLength(): integer
Visibility: this method is public.
Returns: this method returns integer
public function validate( $value ): boolean|ORM\Dbal\Error
Visibility: this method is public.
Returns: this method returns boolean|\ORM\Dbal\Error
Parameter | Type | Description |
---|---|---|
$value |
mixed |