public function GeolocationGeometryContains::buildJoin in Geolocation Field 8.3
Builds the SQL for the join this object represents.
When possible, try to use table alias instead of table names.
Parameters
$select_query: An select query object.
$table: The base table to join.
\Drupal\views\Plugin\views\query\QueryPluginBase $view_query: The source views query.
Overrides JoinPluginBase::buildJoin
File
- modules/
geolocation_geometry/ src/ Plugin/ views/ join/ GeolocationGeometryContains.php, line 20
Class
- GeolocationGeometryContains
- Geometry joins.
Namespace
Drupal\geolocation_geometry\Plugin\views\joinCode
public function buildJoin($select_query, $table, $view_query) {
/** @var \Drupal\Core\Database\Query\Select $select_query */
$geometry_field = ($table['alias'] ?: $this->table) . '.' . $this->field . '_geometry';
$within_field = $this->leftTable . '.' . $this->leftField . '_geometry';
$condition = 'ST_Contains(' . $geometry_field . ', ' . $within_field . ')';
$select_query
->addJoin($this->type, $this->table, $table['alias'], $condition);
}