Lizmap Web Client 3.11.0

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.
PARSER_STATE_BETWEEN_PARAMETERS  : mixed = 0
PARSER_STATE_IN_VALUE  : mixed = 3
PARSER_STATE_PARAM_EQUAL  : mixed = 2
PARSER_STATE_PARAM_NAME  : mixed = 1
PARSER_STATE_SQL_VALUE  : mixed = 10
PARSER_STATE_TABLE_NAME  : mixed = 8
PARSER_STATE_TABLE_NAME_QUOTE  : mixed = 7
PARSER_STATE_TABLE_NAME_SEPARATOR  : mixed = 6
PARSER_STATE_TABLE_SCHEMA  : mixed = 5
PARSER_STATE_TABLE_SQL  : mixed = 9
PARSER_STATE_TABLE_VALUE  : mixed = 4

Properties

$blockSqlWords  : mixed

Methods

parseQgisConnectionString()  : array<string|int, mixed>
Parse a Qgis connection string.
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.

PARSER_STATE_BETWEEN_PARAMETERS

public mixed PARSER_STATE_BETWEEN_PARAMETERS = 0

PARSER_STATE_IN_VALUE

public mixed PARSER_STATE_IN_VALUE = 3

PARSER_STATE_PARAM_EQUAL

public mixed PARSER_STATE_PARAM_EQUAL = 2

PARSER_STATE_PARAM_NAME

public mixed PARSER_STATE_PARAM_NAME = 1

PARSER_STATE_SQL_VALUE

public mixed PARSER_STATE_SQL_VALUE = 10

PARSER_STATE_TABLE_NAME

public mixed PARSER_STATE_TABLE_NAME = 8

PARSER_STATE_TABLE_NAME_QUOTE

public mixed PARSER_STATE_TABLE_NAME_QUOTE = 7

PARSER_STATE_TABLE_NAME_SEPARATOR

public mixed PARSER_STATE_TABLE_NAME_SEPARATOR = 6

PARSER_STATE_TABLE_SCHEMA

public mixed PARSER_STATE_TABLE_SCHEMA = 5

PARSER_STATE_TABLE_SQL

public mixed PARSER_STATE_TABLE_SQL = 9

PARSER_STATE_TABLE_VALUE

public mixed PARSER_STATE_TABLE_VALUE = 4

Properties

$blockSqlWords

protected static mixed $blockSqlWords = array(';', 'select', 'delete', 'insert', 'update', 'drop', 'alter', '--', 'truncate', 'vacuum', 'create', 'reindex', 'grant', 'revoke', '/*')

Methods

parseQgisConnectionString()

Parse a Qgis connection string.

public static parseQgisConnectionString(string $connection_string) : array<string|int, mixed>

It supports table and sql parameters, as well as geometry tags like (geom), in addition of other database connection parameters.

It is compliant with the Qgis 4.2 parser.

Parameters
$connection_string : string
Tags
see
https://api.qgis.org/api/4.2/qgsdatasourceuri_8cpp_source.html
throws
QgisConnectionStringParserException
Return values
array<string|int, mixed>

the list of parameters

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: list}

returns if the expression does not contains dangerous chars, and the list of blocked items

On this page

Search results