Doctrine Project

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Doctrine MongoDB ODM
  • Doctrine MongoDB ODM
  • MODM-153

"Near" Query does not work.

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Critical Critical
  • Resolution: Unresolved
  • Affects Version/s: 1.0.0BETA2
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

"Near" statement does not work for me. The following code returns all cities from collection:

$cities = $this->dm->createQuery('City')
    ->field('coordinates')->near(50, 60)
    ->execute();

Could you please fix it?

Activity

Descending order - Click to sort in ascending order
  • All
  • Comments
  • History
  • Activity
  • Source
Hide
Permalink
Shane A. Stillwell added a comment - 20/Feb/12 7:54 PM

I had the same issue on 1.0.0.BETA3.

The solution was to change the query up a little.

$places = $this->dm->createQueryBuilder('\Application\Event')->field('latitude')->near(50)->field('longitude')->near(60)->getQuery()->execute(); 

http://stackoverflow.com/a/9015906/179335

Show
Shane A. Stillwell added a comment - 20/Feb/12 7:54 PM I had the same issue on 1.0.0.BETA3. The solution was to change the query up a little. $places = $this->dm->createQueryBuilder('\Application\Event')->field('latitude')->near(50)->field('longitude')->near(60)->getQuery()->execute(); http://stackoverflow.com/a/9015906/179335
Hide
Permalink
Tim Sakharchuk added a comment - 04/Sep/11 7:10 PM - edited

Hi All,

Here is correct realization of this function in
Doctrine\MongoDB\Query\Builder

public function near($x, $y)

{ $this->query['type'] = Query::TYPE_GEO_LOCATION; $this->query['near'] = array($x, $y); return $this; }

When may this fix appear in Doctrine ODM?

Thanks!

Show
Tim Sakharchuk added a comment - 04/Sep/11 7:10 PM - edited Hi All, Here is correct realization of this function in Doctrine\MongoDB\Query\Builder public function near($x, $y) { $this->query['type'] = Query::TYPE_GEO_LOCATION; $this->query['near'] = array($x, $y); return $this; } When may this fix appear in Doctrine ODM? Thanks!
Hide
Permalink
mark wright added a comment - 02/Sep/11 4:11 AM

It also does not work in beta3 but it fails differently. It never returns anything.

$places = $documentManager->createQueryBuilder('Documents\Place')
->field('point')
->near(36.5788494, -121.7207804)
->getQuery()
->execute();

This returns 0 documents even though I have a point at 36.5788493, -121.7207805. Doctrine\MongoDB\Query\Builder::near() only takes one argument so the Y value is ignored. However, the docblock specifies 2 params.

Show
mark wright added a comment - 02/Sep/11 4:11 AM It also does not work in beta3 but it fails differently. It never returns anything. $places = $documentManager->createQueryBuilder('Documents\Place') ->field('point') ->near(36.5788494, -121.7207804) ->getQuery() ->execute(); This returns 0 documents even though I have a point at 36.5788493, -121.7207805. Doctrine\MongoDB\Query\Builder::near() only takes one argument so the Y value is ignored. However, the docblock specifies 2 params.

People

  • Assignee:
    Jonathan H. Wage
    Reporter:
    Dmitry
Vote (0)
Watch (0)

Dates

  • Created:
    10/Aug/11 12:55 PM
    Updated:
    20/Feb/12 7:54 PM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Doctrine Project. Try JIRA - bug tracking software for your team.