public function hasSingleResult($name) {
        $parts = explode(".", $name);
        $nameSoFar = "";
        foreach ($parts as $part) {
            $lastNameSoFar = $nameSoFar;
            $nameSoFar .= ($nameSoFar ? '.' : '') . $part;
            if (!isset($this->relations[$nameSoFar])) {
                $this->relations[$nameSoFar] = $this->initSubRelation($nameSoFar, $this->relations[$lastNameSoFar]);
            }
            if (!$this->relations[$nameSoFar]->hasSingleResult()) {
                if (!isset($this->toBeSelectedSeparately[$nameSoFar])) {
                    $this->toBeSelectedSeparately[$nameSoFar] = [
                        'relation' => $this->relations[$nameSoFar],
                        'subrelations' => []
                    ];
                }
                if ($nameSoFar != $name) {
                    $this->toBeSelectedSeparately[$nameSoFar]['subrelations'][] = substr($name, strlen($nameSoFar) + 1); // also keep name for separate select
                }
                return false;
            }
        }
        return true;
    }
public function hasSingleResult($name) {
        $parts = explode(".", $name);
        $nameSoFar = "";
        foreach ($parts as $part) {
            $lastNameSoFar = $nameSoFar;
            $nameSoFar .= ($nameSoFar ? '.' : '') . $part;
            if (!isset($this->relations[$nameSoFar])) {
                $this->relations[$nameSoFar] = $this->initSubRelation($nameSoFar, $this->relations[$lastNameSoFar]);
            }
            if (!$this->relations[$nameSoFar]->hasSingleResult()) {
                if (!isset($this->toBeSelectedSeparately[$nameSoFar])) {
                    $this->toBeSelectedSeparately[$nameSoFar] = [
                        'relation' => $this->relations[$nameSoFar],
                        'subrelations' => []
                    ];
                }
                if ($nameSoFar != $name) {
                    $this->toBeSelectedSeparately[$nameSoFar]['subrelations'][] = substr($name, strlen($nameSoFar) + 1); // also keep name for separate select
                }
                return false;
            }
        }
        return true;
    }
public function hasSingleResult ( $ name ) { $ parts = explode ( "." , $ name ) ; $ nameSoFar = "" ; foreach ( $ parts as $ part ) { $ lastNameSoFar = $ nameSoFar ; $ nameSoFar .= ( $ nameSoFar ? '.' : '' ) . $ part ; if ( ! isset ( $ this -> relations [ $ nameSoFar ] ) ) { $ this -> relations [ $ nameSoFar ] = $ this -> initSubRelation ( $ nameSoFar , $ this -> relations [ $ lastNameSoFar ] ) ; } if ( ! $ this -> relations [ $ nameSoFar ] -> hasSingleResult ( ) ) { if ( ! isset ( $ this -> toBeSelectedSeparately [ $ nameSoFar ] ) ) { $ this -> toBeSelectedSeparately [ $ nameSoFar ] = [ 'relation' => $ this -> relations [ $ nameSoFar ] , 'subrelations' => [ ] ] ; } if ( $ nameSoFar != $ name ) { $ this -> toBeSelectedSeparately [ $ nameSoFar ] [ 'subrelations' ] [ ] = substr ( $ name , strlen ( $ nameSoFar ) + 1 ) ; // also keep name for separate select } return false ; } } return true ; }
Checks if the relation returns a single result. It also checks for parents if it's a relation of a relation.
@param $name
@return bool
Checks if the relation returns a single result . It also checks for parents if it s a relation of a relation .