Пример #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
 /**
  *  get a field instance for the given name
  *  
  *  this will return any previously set field instance if it exists, if it doesn't
  *  then it will create a new one so it guarrantees to always return an mingo_field
  *  instance         
  *
  *  @param  string|array  $name the field's name   
  *  @return mingo_field
  */
 public function getField($name, $default_val = null)
 {
     $ret_instance = parent::getField($name, null);
     if ($ret_instance === null) {
         $ret_instance = new MingoField($name);
         $ret_instance->setDefaultVal($default_val);
     }
     //if
     return $ret_instance;
 }