abstract class SQLFilter (View source)

The base class that user defined filters should extend.

Handles the setting and escaping of parameters.

Methods

__construct(EntityManagerInterface $em)

No description

setParameter(string $name, string $value, string|null $type = null)

Sets a parameter that can be used by the filter.

string
getParameter(string $name)

Gets a parameter to use in a query.

bool
hasParameter(string $name)

Checks if a parameter was set for the filter.

string
__toString()

Returns as string representation of the SQLFilter parameters (the state).

Connection
getConnection()

Returns the database connection used by the entity manager

string
addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)

Gets the SQL query part to add to a query.

Details

final __construct(EntityManagerInterface $em)

Parameters

EntityManagerInterface $em The entity manager.

final SQLFilter setParameter(string $name, string $value, string|null $type = null)

Sets a parameter that can be used by the filter.

Parameters

string $name Name of the parameter.
string $value Value of the parameter.
string|null $type The parameter type. If specified, the given value will be run through the type conversion of this type. This is usually not needed for strings and numeric types.

Return Value

SQLFilter The current SQL filter.

final string getParameter(string $name)

Gets a parameter to use in a query.

The function is responsible for the right output escaping to use the value in a query.

Parameters

string $name Name of the parameter.

Return Value

string The SQL escaped parameter to use in a query.

Exceptions

InvalidArgumentException

final bool hasParameter(string $name)

Checks if a parameter was set for the filter.

Parameters

string $name Name of the parameter.

Return Value

bool

final string __toString()

Returns as string representation of the SQLFilter parameters (the state).

Return Value

string String representation of the SQLFilter.

final protected Connection getConnection()

Returns the database connection used by the entity manager

Return Value

Connection

abstract string addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)

Gets the SQL query part to add to a query.

Parameters

ClassMetadata $targetEntity
$targetTableAlias

Return Value

string The constraint SQL if there is available, empty string otherwise.