1

It seems like most Craft queries contain GROUP BY elements.id but this seems to clash with a HAVING clause when using the Smart Map plugin.

Where does this come from and is it possible to override/remove this?

1
  • Can you edit the question to include the template code you're attempting to use as well any any errors you might be getting? – Brad Bell Sep 15 '15 at 17:13
1

The HAVING clause comes from this piece of code:

// Modify query
$query
    ->addSelect($haversine.' AS distance')
    ->having('distance <= '.$filter->range)
;

The variables going into this query modification are:

  • $haversine - A complex formula which determines the relative distance of each address from the center point.
  • $filter->range - The maximum search distance. (defaults to 25)

This code exists so that your proximity search results can be sorted by closest locations. It will be triggered any time you chain this into your Twig query:

.myFieldHandle(params)

You can see the full details of how this all ties together in the documentation here:

https://plugins.doublesecretagency.com/smart-map/sorting-entries-by-closest-locations/

There should be no conflict with any existing GROUP BY clause... Smart Map does not set or modify that aspect of the query. And there is no inherent conflict between HAVING and GROUP BY, as demonstrated by this w3schools example, which utilizes both in combination.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.