SqlTools
in package
Table of Contents
Constants
- GEOMETRY_PREDICATES : array<string, string> = array('intersects' => 'ST_Intersects', 'contain...
- QGIS geometry predicate functions mapped to their PostGIS ST_* equivalents.
Properties
- $blockSqlWords : mixed
Methods
- translateExpressionToPostgis() : string
- Translate a QGIS expression filter into a PostGIS compatible SQL filter.
-
validateExpressionFilter()
: array{0: bool, 1: list
} - Validate an expression filter.
Constants
GEOMETRY_PREDICATES
QGIS geometry predicate functions mapped to their PostGIS ST_* equivalents.
public
array<string, string>
GEOMETRY_PREDICATES
= array('intersects' => 'ST_Intersects', 'contains' => 'ST_Contains', 'within' => 'ST_Within', 'crosses' => 'ST_Crosses', 'overlaps' => 'ST_Overlaps', 'touches' => 'ST_Touches', 'disjoint' => 'ST_Disjoint')
These are the operators offered by the selection tool and the filter form.
Properties
$blockSqlWords
protected
static mixed
$blockSqlWords
= array(';', 'select', 'delete', 'insert', 'update', 'drop', 'alter', '--', 'truncate', 'vacuum', 'create', 'reindex', 'grant', 'revoke', '/*')
Methods
translateExpressionToPostgis()
Translate a QGIS expression filter into a PostGIS compatible SQL filter.
public
static translateExpressionToPostgis(string $filter, string $geometryColumn) : string
Rewrites the geometry predicate functions used by the selection tool and the filter form (intersects, contains, within, crosses, overlaps, touches, disjoint) to their PostGIS ST_* equivalents, translates geom_from_gml() and replaces the $geometry variable with the given geometry column.
The predicate name is matched case-insensitively and only when followed by an opening parenthesis, so plain text and column names are left untouched.
Parameters
- $filter : string
-
The QGIS expression filter
- $geometryColumn : string
-
The layer geometry column name
Return values
string —The PostGIS compatible filter
validateExpressionFilter()
Validate an expression filter.
public
static validateExpressionFilter(string $filter) : array{0: bool, 1: list}
Parameters
- $filter : string
-
The expression filter to validate
Return values
array{0: bool, 1: listreturns if the expression does not contains dangerous chars, and the list of blocked items