SQLFilter
in package
The base class that user defined filters should extend.
Handles the setting and escaping of parameters.
Tags
Table of Contents
- $em : EntityManagerInterface
- The entity manager.
- $parameters : mixed
- Parameters for the filter.
- __construct() : mixed
- __toString() : string
- Returns as string representation of the SQLFilter parameters (the state).
- addFilterConstraint() : string
- Gets the SQL query part to add to a query.
- getParameter() : string
- Gets a parameter to use in a query.
- getParameterList() : string
- Gets a parameter to use in a query assuming it's a list of entries.
- hasParameter() : bool
- Checks if a parameter was set for the filter.
- setParameter() : $this
- Sets a parameter that can be used by the filter.
- setParameterList() : $this
- Sets a parameter list that can be used by the filter.
- getConnection() : Connection
- Returns the database connection used by the entity manager
Properties
$em
The entity manager.
private
EntityManagerInterface
$em
$parameters
Parameters for the filter.
private
mixed
$parameters
= []
Tags
Methods
__construct()
public
final __construct(EntityManagerInterface $em) : mixed
Parameters
- $em : EntityManagerInterface
-
The entity manager.
Return values
mixed —__toString()
Returns as string representation of the SQLFilter parameters (the state).
public
final __toString() : string
Return values
string —String representation of the SQLFilter.
addFilterConstraint()
Gets the SQL query part to add to a query.
public
abstract addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias) : string
Parameters
- $targetEntity : ClassMetadata
- $targetTableAlias : string
Return values
string —The constraint SQL if there is available, empty string otherwise.
getParameter()
Gets a parameter to use in a query.
public
final getParameter(string $name) : string
The function is responsible for the right output escaping to use the value in a query.
Parameters
- $name : string
-
Name of the parameter.
Tags
Return values
string —The SQL escaped parameter to use in a query.
getParameterList()
Gets a parameter to use in a query assuming it's a list of entries.
public
final getParameterList(string $name) : string
The function is responsible for the right output escaping to use the value in a query, separating each entry by comma to inline it into an IN() query part.
Parameters
- $name : string
-
Name of the parameter.
Tags
Return values
string —The SQL escaped parameter to use in a query.
hasParameter()
Checks if a parameter was set for the filter.
public
final hasParameter(string $name) : bool
Parameters
- $name : string
-
Name of the parameter.
Return values
bool —setParameter()
Sets a parameter that can be used by the filter.
public
final setParameter(string $name, mixed $value[, string|null $type = null ]) : $this
Parameters
- $name : string
-
Name of the parameter.
- $value : mixed
-
Value of the parameter.
- $type : string|null = null
-
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 values
$this —setParameterList()
Sets a parameter list that can be used by the filter.
public
final setParameterList(string $name, array<string|int, mixed> $values[, string $type = Types::STRING ]) : $this
Parameters
- $name : string
-
Name of the parameter.
- $values : array<string|int, mixed>
-
List of parameter values.
- $type : string = Types::STRING
-
The parameter type. If specified, the given value will be run through the type conversion of this type.
Return values
$this —getConnection()
Returns the database connection used by the entity manager
protected
final getConnection() : Connection