/** * * Prepare an SQL WHERE clause from input filterName * * @param RestoModel $model (with model keys) * @param array $requestParams (with model keys) * @param string $filterName * @param boolean $exclusion : if true, exclude instead of include filter (WARNING ! only works for geometry and keywords) * */ private function prepareFilterQuery($model, $requestParams, $filterName, $exclusion = false) { /* * Special case - dates */ if ($model->getDbType($model->searchFilters[$filterName]['key']) === 'date') { return $this->prepareFilterQuery_date($model, $filterName, $requestParams); } /* * Special case identifier - use productIdentifier or identifier */ if ($filterName === 'geo:uid' && !RestoUtil::isValidUUID($requestParams['geo:uid'])) { return $model->getDbKey('productIdentifier') . ' = \'' . pg_escape_string($requestParams['geo:uid']) . '\''; } /* * Prepare filter from operation */ switch ($model->searchFilters[$filterName]['operation']) { /* * Keywords i.e. searchTerms */ case 'keywords': return $this->prepareFilterQuery_keywords($model, $filterName, $requestParams, $exclusion); /* * Intersects i.e. geo:* */ /* * Intersects i.e. geo:* */ case 'intersects': return $this->prepareFilterQuery_intersects($model, $filterName, $requestParams, $exclusion); /* * Distance i.e. geo:lon, geo:lat and geo:radius */ /* * Distance i.e. geo:lon, geo:lat and geo:radius */ case 'distance': return $this->prepareFilterQuery_distance($model, $filterName, $requestParams, $exclusion); /* * Intervals */ /* * Intervals */ case 'interval': return $this->prepareFilterQuery_interval($model, $filterName, $requestParams); /* * Simple case - non 'interval' operation on value or arrays */ /* * Simple case - non 'interval' operation on value or arrays */ default: return $this->prepareFilterQuery_general($model, $filterName, $requestParams, $model->getDbType($model->searchFilters[$filterName]['key'])); } }