Doctrine\MongoDB\Query\Expr::near PHP Method

near() public method

A GeoJSON point may be provided as the first and only argument for 2dsphere queries. This single parameter may be a GeoJSON point object or an array corresponding to the point's JSON representation.
See also: Builder::near()
See also: http://docs.mongodb.org/manual/reference/operator/near/
public near ( float | array | GeoJson\Geometry\Point $x, float $y = null )
$x float | array | GeoJson\Geometry\Point
$y float
    public function near($x, $y = null)
    {
        if ($x instanceof Point) {
            $x = $x->jsonSerialize();
        }
        if (is_array($x)) {
            return $this->operator('$near', ['$geometry' => $x]);
        }
        return $this->operator('$near', [$x, $y]);
    }

Usage Example

示例#1
0
文件: ExprTest.php 项目: im286er/ent
 public function testMaxDistanceWithNearAndLegacyCoordinates()
 {
     $expr = new Expr();
     $expr->near(1, 2);
     $this->assertSame($expr, $expr->maxDistance(1));
     $this->assertEquals(array('$near' => array(1, 2), '$maxDistance' => 1), $expr->getQuery());
 }
All Usage Examples Of Doctrine\MongoDB\Query\Expr::near