PHP Class Sokil\Mongo\Expression

Inheritance: implements Sokil\Mongo\ArrayableInterface
Show file Open project: sokil/php-mongo Class Usage Examples

Protected Properties

Property Type Description
$_expression

Public Methods

Method Description
convertToArray ( mixed $mixed ) : array Transform expression in different formats to canonical array form
expression ( ) : Expression Create new instance of expression
intersects ( string $field, GeoJson\Geometry\Geometry $geometry ) : Expression Selects documents whose geospatial data intersects with a specified GeoJSON object; i.e. where the intersection of the data and the specified object is non-empty. This includes cases where the data and the specified object share an edge. Uses spherical geometry.
merge ( Expression $expression )
nearPoint ( string $field, float $longitude, float $latitude, integer | array $distance ) : Expression Find document near points in flat surface
nearPointSpherical ( string $field, float $longitude, float $latitude, integer | array $distance ) : Expression Find document near points in spherical surface
toArray ( )
where ( $field, $value ) : Cursor | Expression Return a expression
whereAll ( string $field, array $values ) : Expression Find documents where the value of a field is an array that contains all the specified elements.
whereAnd ( array | Expression $expressions = null ) : Expression Select the documents that satisfy all the expressions in the array
whereAny ( string $field, array $values ) : Expression Find documents where the value of a field is an array that contains any of the specified elements.
whereArray ( $field )
whereArrayOfArrays ( $field )
whereArraySize ( string $field, integer $length ) : Expression Selects documents if the array field is a specified size.
whereBoolean ( $field )
whereDate ( $field )
whereDouble ( $field )
whereElemMatch ( string $field, Expression | callable | array $expression ) : Expression Matches documents in a collection that contain an array field with at least one element that matches all the specified query criteria.
whereElemNotMatch ( type $field, Expression | callable | array $expression ) : Expression Matches documents in a collection that contain an array field with elements that do not matches all the specified query criteria.
whereEmpty ( $field )
whereExists ( $field )
whereGreater ( $field, $value )
whereGreaterOrEqual ( $field, $value )
whereHasType ( $field, $type )
whereIn ( string $field, array $values ) : Expression Selects the documents where the value of a field equals any value in the specified array.
whereJsCondition ( $condition )
whereLess ( $field, $value )
whereLessOrEqual ( $field, $value )
whereLike ( $field, $regex, $caseInsensitive = true )
whereMod ( string $field, integer $divisor, integer $remainder ) Select documents where the value of a field divided by a divisor has the specified remainder (i.e. perform a modulo operation to select documents)
whereNoneOf ( string $field, array $values ) : Expression Find documents where the value of a field is an array that contains none of the specified elements.
whereNor ( array | Expression $expressions = null ) : Expression Selects the documents that fail all the query expressions in the array
whereNot ( Expression $expression )
whereNotEmpty ( $field )
whereNotEqual ( $field, $value )
whereNotExists ( $field )
whereNotIn ( $field, array $values )
whereNull ( $field )
whereObject ( $field )
whereObjectId ( $field )
whereOr ( array | Expression $expressions = null ) : Expression Selects the documents that satisfy at least one of the expressions
whereString ( $field )
whereText ( $search, $language = null, boolean | false $caseSensitive = null, boolean | false $diacriticSensitive = null ) Perform fulltext search
within ( string $field, GeoJson\Geometry\Geometry $geometry ) : Expression Selects documents with geospatial data that exists entirely within a specified shape.
withinBox ( string $field, array $bottomLeftCoordinate, array $upperRightCoordinate ) : Expression Return documents that are within the bounds of the rectangle, according to their point-based location data.
withinCircle ( string $field, float $longitude, float $latitude, float $radius ) : Expression Select documents with geospatial data within circle defined by center point and radius in flat surface
withinCircleSpherical ( string $field, float $longitude, float $latitude, float $radiusInRadians ) : Expression Select documents with geospatial data within circle defined by center point and radius in spherical surface
withinPolygon ( string $field, array $points ) : Expression Return documents that are within the polygon, according to their point-based location data.

Method Details

convertToArray() public static method

Transform expression in different formats to canonical array form
public static convertToArray ( mixed $mixed ) : array
$mixed mixed
return array

expression() public method

Create new instance of expression
public expression ( ) : Expression
return Expression

intersects() public method

Selects documents whose geospatial data intersects with a specified GeoJSON object; i.e. where the intersection of the data and the specified object is non-empty. This includes cases where the data and the specified object share an edge. Uses spherical geometry.
public intersects ( string $field, GeoJson\Geometry\Geometry $geometry ) : Expression
$field string
$geometry GeoJson\Geometry\Geometry
return Expression

merge() public method

public merge ( Expression $expression )
$expression Expression

nearPoint() public method

Find document near points in flat surface
public nearPoint ( string $field, float $longitude, float $latitude, integer | array $distance ) : Expression
$field string
$longitude float
$latitude float
$distance integer | array distance from point in meters. Array distance allowed only in MongoDB 2.6
return Expression

nearPointSpherical() public method

Find document near points in spherical surface
public nearPointSpherical ( string $field, float $longitude, float $latitude, integer | array $distance ) : Expression
$field string
$longitude float
$latitude float
$distance integer | array distance from point in meters. Array distance allowed only in MongoDB 2.6
return Expression

toArray() public method

public toArray ( )

where() public method

Return a expression
public where ( $field, $value ) : Cursor | Expression
return Cursor | Expression

whereAll() public method

This is equivalent of logical AND.
public whereAll ( string $field, array $values ) : Expression
$field string point-delimited field name
$values array
return Expression

whereAnd() public method

Select the documents that satisfy all the expressions in the array
public whereAnd ( array | Expression $expressions = null ) : Expression
$expressions array | Expression Array of Expression instances or comma delimited expression list
return Expression

whereAny() public method

This is equivalent of logical AND.
public whereAny ( string $field, array $values ) : Expression
$field string point-delimited field name
$values array
return Expression

whereArray() public method

public whereArray ( $field )

whereArrayOfArrays() public method

public whereArrayOfArrays ( $field )

whereArraySize() public method

Selects documents if the array field is a specified size.
public whereArraySize ( string $field, integer $length ) : Expression
$field string
$length integer
return Expression

whereBoolean() public method

public whereBoolean ( $field )

whereDate() public method

public whereDate ( $field )

whereDouble() public method

public whereDouble ( $field )

whereElemMatch() public method

Matches documents in a collection that contain an array field with at least one element that matches all the specified query criteria.
public whereElemMatch ( string $field, Expression | callable | array $expression ) : Expression
$field string point-delimited field name
$expression Expression | callable | array
return Expression

whereElemNotMatch() public method

Matches documents in a collection that contain an array field with elements that do not matches all the specified query criteria.
public whereElemNotMatch ( type $field, Expression | callable | array $expression ) : Expression
$field type
$expression Expression | callable | array
return Expression

whereEmpty() public method

public whereEmpty ( $field )

whereExists() public method

public whereExists ( $field )

whereGreater() public method

public whereGreater ( $field, $value )

whereGreaterOrEqual() public method

public whereGreaterOrEqual ( $field, $value )

whereHasType() public method

public whereHasType ( $field, $type )

whereIn() public method

Selects the documents where the value of a field equals any value in the specified array.
public whereIn ( string $field, array $values ) : Expression
$field string
$values array
return Expression

whereJsCondition() public method

public whereJsCondition ( $condition )

whereLess() public method

public whereLess ( $field, $value )

whereLessOrEqual() public method

public whereLessOrEqual ( $field, $value )

whereLike() public method

public whereLike ( $field, $regex, $caseInsensitive = true )

whereMod() public method

Select documents where the value of a field divided by a divisor has the specified remainder (i.e. perform a modulo operation to select documents)
public whereMod ( string $field, integer $divisor, integer $remainder )
$field string
$divisor integer
$remainder integer

whereNoneOf() public method

This is equivalent of logical AND.
public whereNoneOf ( string $field, array $values ) : Expression
$field string point-delimited field name
$values array
return Expression

whereNor() public method

Selects the documents that fail all the query expressions in the array
public whereNor ( array | Expression $expressions = null ) : Expression
$expressions array | Expression Array of Expression instances or comma delimited expression list
return Expression

whereNot() public method

public whereNot ( Expression $expression )
$expression Expression

whereNotEmpty() public method

public whereNotEmpty ( $field )

whereNotEqual() public method

public whereNotEqual ( $field, $value )

whereNotExists() public method

public whereNotExists ( $field )

whereNotIn() public method

public whereNotIn ( $field, array $values )
$values array

whereNull() public method

public whereNull ( $field )

whereObject() public method

public whereObject ( $field )

whereObjectId() public method

public whereObjectId ( $field )

whereOr() public method

Selects the documents that satisfy at least one of the expressions
public whereOr ( array | Expression $expressions = null ) : Expression
$expressions array | Expression Array of Expression instances or comma delimited expression list
return Expression

whereString() public method

public whereString ( $field )

whereText() public method

Perform fulltext search
public whereText ( $search, $language = null, boolean | false $caseSensitive = null, boolean | false $diacriticSensitive = null )
$search A string of terms that MongoDB parses and uses to query the text index. MongoDB performs a logical OR search of the terms unless specified as a phrase.
$language Optional. The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer. If not specified, the search uses the default language of the index. If you specify a language value of "none", then the text search uses simple tokenization with no list of stop words and no stemming.
$caseSensitive boolean | false Allowed from v.3.2 A boolean flag to enable or disable case sensitive search. Defaults to false; i.e. the search defers to the case insensitivity of the text index.
$diacriticSensitive boolean | false Allowed from v.3.2 A boolean flag to enable or disable diacritic sensitive search against version 3 text indexes. Defaults to false; i.e. the search defers to the diacritic insensitivity of the text index. Text searches against earlier versions of the text index are inherently diacritic sensitive and cannot be diacritic insensitive. As such, the $diacriticSensitive option has no effect with earlier versions of the text index.

within() public method

Selects documents with geospatial data that exists entirely within a specified shape.
public within ( string $field, GeoJson\Geometry\Geometry $geometry ) : Expression
$field string
$geometry GeoJson\Geometry\Geometry
return Expression

withinBox() public method

Based on grid coordinates and does not query for GeoJSON shapes. Use planar geometry, so 2d index may be used but not required
public withinBox ( string $field, array $bottomLeftCoordinate, array $upperRightCoordinate ) : Expression
$field string
$bottomLeftCoordinate array Bottom left coordinate of box
$upperRightCoordinate array Upper right coordinate of box
return Expression

withinCircle() public method

Select documents with geospatial data within circle defined by center point and radius in flat surface
public withinCircle ( string $field, float $longitude, float $latitude, float $radius ) : Expression
$field string
$longitude float
$latitude float
$radius float
return Expression

withinCircleSpherical() public method

To calculate distance in radians
See also: http://docs.mongodb.org/manual/tutorial/calculate-distances-using-spherical-geometry-with-2d-geospatial-indexes/
public withinCircleSpherical ( string $field, float $longitude, float $latitude, float $radiusInRadians ) : Expression
$field string
$longitude float
$latitude float
$radiusInRadians float in radians.
return Expression

withinPolygon() public method

Based on grid coordinates and does not query for GeoJSON shapes. Use planar geometry, so 2d index may be used but not required
public withinPolygon ( string $field, array $points ) : Expression
$field string
$points array array of coordinates
return Expression

Property Details

$_expression protected property

protected $_expression