public function findRelatedModels($modelName, $field, $id = NULL) {
    $relatedModel = $this->getInstance($modelName);

    if ($this->isNew() && $id === NULL) {
      throw new \Exception('No id for related');
    }

    if ($id === NULL) {
      $id = $this->getId();
    }

    $result = $relatedModel->findByField($field, $id);

    return $result;
  }
public function findRelatedModels($modelName, $field, $id = NULL) {
    $relatedModel = $this->getInstance($modelName);

    if ($this->isNew() && $id === NULL) {
      throw new \Exception('No id for related');
    }

    if ($id === NULL) {
      $id = $this->getId();
    }

    $result = $relatedModel->findByField($field, $id);

    return $result;
  }
public function findRelatedModels ( $ modelName , $ field , $ id = NULL ) { $ relatedModel = $ this -> getInstance ( $ modelName ) ; if ( $ this -> isNew ( ) && $ id === NULL ) { throw new \ Exception ( 'No id for related' ) ; } if ( $ id === NULL ) { $ id = $ this -> getId ( ) ; } $ result = $ relatedModel -> findByField ( $ field , $ id ) ; return $ result ; }
Finds related models instances using the field name and the id value.

Use it in a 1 to N relation, with an object instance of the 1 side to the get N related models.

@param $modelName : The related model name.
@param $field : The field that must be used to relate.
@param $id : Optional, the ID the related model, if is not given the value of the field in the executor object will be used.

@throws \Exception : if a invalid model is given.

@return Related Instance.
Finds related models instances using the field name and the id value .