Пример #1
0
 /**
  *  handle a spatial call
  *  
  *  the form is taken from: http://www.mongodb.org/display/DOCS/Geospatial+Indexing
  *           
  *  @since  10-18-10
  *  @param  string  $name the field name
  *  @param  array $point  a latitude and longitude point
  *  @param  integer $distance the radius around the point
  *  @return MingoCriteria   
  */
 public function nearField($name, $point, $distance)
 {
     // canary, make sure the point is valid...
     $field = new MingoField();
     $field->setType(MingoField::TYPE_POINT);
     $point = $field->normalizeInVal($point);
     $near_command = $this->normalizeCommand('near');
     $val = array($near_command => $point, $this->normalizeCommand('maxDistance') => (int) $distance);
     return $this->setWhereVal($name, '', $val, array($near_command));
 }
Пример #2
0
 /**
  *  set a field that this class can then use internally
  *      
  *  @since  4-26-11
  *  @param  string  $name the name of the field
  *  @param  integer $type the type of the field, one of the MingoField::TYPE_* constants         
  */
 public function setField($name, $type)
 {
     $field = new MingoField($name);
     $field->setType($type);
     return $this->addField($field);
 }