Skip to content
This repository was archived by the owner on Nov 4, 2019. It is now read-only.
This repository was archived by the owner on Nov 4, 2019. It is now read-only.

Separate distance column method in query class #27

@smhg

Description

@smhg

I think it would be great to have the Distance column as a separate query method (something like withDistance).

That would facilitate making custom queries like

XxxQuery::create()
  ->withDistance($latitude, $longitude)
  ->limit(10)
  ->orderByDistance()
  ->find();

to find the 10 closest matches to a specific location.

What do you think?

One difficulty: is there a way around the re-use of the prepared statement in the where clause in filterByDistanceFrom?

A less disruptive option is to make the $distance parameter to filterByDistanceFrom optional (and not add the where clause when null).
I personally like the modularity of withDistance though.

I'm happy to send a PR after your feedback.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions