public function RecurseFieldMaps($typename, $fms)
	{

		// if we see the same table again, we have an infinite loop
		if (isset($this->_keymapcache[$typename]))
		{
			// return;  // TODO: why doesn't this work..?
			throw new Exception("A circular EAGER join was detected while parsing `$typename`.  This is possibly due to an EAGER join with `".$this->_prevkeymap."`  Please edit your Map so that at least one side of the join is LAZY.");
		}

		// first we just add the basic columns of this object
		foreach ($fms as $fm)
		{
			$this->AddFieldMap($fm);
		}
		
		// get the keymaps for the requested object
		$kms = $this->_phreezer->GetKeyMaps($typename);
		$this->_keymapcache[$typename] = $kms;  // save this to prevent infinite loop
		$this->_prevkeymap = $typename;
		
		// each keymap in this object that is eagerly loaded, we want to join into the query.
		// each of these tables, then might have eagerly loaded keymaps as well, so we'll use
		// recursion to eagerly load as much of the graph as is desired
		foreach ($kms as $km)
		{
			if ($km->LoadType == KM_LOAD_EAGER || $km->LoadType == KM_LOAD_INNER)
			{
				// check that we didn't eagerly join this already.
				// TODO: use aliases to support multiple eager joins to the same table
				if (isset($this->Joins[$km->ForeignObject . "_is_joined"]))
				{
					//print_r($typename);
					throw new Exception($typename ."Map has multiple EAGER joins to `" . $km->ForeignObject . "` which is not yet supported by Phreeze.");
				}
				
				$ffms = $this->_phreezer->GetFieldMaps($km->ForeignObject);
				
				$this->RecurseFieldMaps($km->ForeignObject, $ffms);
				
				// lastly we need to add the join information for this foreign field map
				$jointype = $km->LoadType == KM_LOAD_INNER ? "inner" : "left";
				
				foreach ($ffms as $ffm)
				{
					if (!isset($this->Joins[$ffm->TableName]))
					{
						$this->Joins[$ffm->TableName] = " ".$jointype." join `".$ffm->TableName."` on `" . $fms[$km->KeyProperty]->TableName . "`.`" .  $fms[$km->KeyProperty]->ColumnName . "` = `" . $ffms[$km->ForeignKeyProperty]->TableName . "`.`" . $ffms[$km->ForeignKeyProperty]->ColumnName . "`";
					}

				}
				
				// keep track of what we have eagerly joined already
				$this->Joins[$km->ForeignObject . "_is_joined"] = 1;
			}
		}
	}
public function RecurseFieldMaps($typename, $fms)
	{

		// if we see the same table again, we have an infinite loop
		if (isset($this->_keymapcache[$typename]))
		{
			// return;  // TODO: why doesn't this work..?
			throw new Exception("A circular EAGER join was detected while parsing `$typename`.  This is possibly due to an EAGER join with `".$this->_prevkeymap."`  Please edit your Map so that at least one side of the join is LAZY.");
		}

		// first we just add the basic columns of this object
		foreach ($fms as $fm)
		{
			$this->AddFieldMap($fm);
		}
		
		// get the keymaps for the requested object
		$kms = $this->_phreezer->GetKeyMaps($typename);
		$this->_keymapcache[$typename] = $kms;  // save this to prevent infinite loop
		$this->_prevkeymap = $typename;
		
		// each keymap in this object that is eagerly loaded, we want to join into the query.
		// each of these tables, then might have eagerly loaded keymaps as well, so we'll use
		// recursion to eagerly load as much of the graph as is desired
		foreach ($kms as $km)
		{
			if ($km->LoadType == KM_LOAD_EAGER || $km->LoadType == KM_LOAD_INNER)
			{
				// check that we didn't eagerly join this already.
				// TODO: use aliases to support multiple eager joins to the same table
				if (isset($this->Joins[$km->ForeignObject . "_is_joined"]))
				{
					//print_r($typename);
					throw new Exception($typename ."Map has multiple EAGER joins to `" . $km->ForeignObject . "` which is not yet supported by Phreeze.");
				}
				
				$ffms = $this->_phreezer->GetFieldMaps($km->ForeignObject);
				
				$this->RecurseFieldMaps($km->ForeignObject, $ffms);
				
				// lastly we need to add the join information for this foreign field map
				$jointype = $km->LoadType == KM_LOAD_INNER ? "inner" : "left";
				
				foreach ($ffms as $ffm)
				{
					if (!isset($this->Joins[$ffm->TableName]))
					{
						$this->Joins[$ffm->TableName] = " ".$jointype." join `".$ffm->TableName."` on `" . $fms[$km->KeyProperty]->TableName . "`.`" .  $fms[$km->KeyProperty]->ColumnName . "` = `" . $ffms[$km->ForeignKeyProperty]->TableName . "`.`" . $ffms[$km->ForeignKeyProperty]->ColumnName . "`";
					}

				}
				
				// keep track of what we have eagerly joined already
				$this->Joins[$km->ForeignObject . "_is_joined"] = 1;
			}
		}
	}
public function RecurseFieldMaps ( $ typename , $ fms ) { // if we see the same table again, we have an infinite loop
 if ( isset ( $ this -> _keymapcache [ $ typename ] ) ) { // return;  // TODO: why doesn't this work..?
 throw new Exception ( "A circular EAGER join was detected while parsing `$typename`.  This is possibly due to an EAGER join with `" . $ this -> _prevkeymap . "`  Please edit your Map so that at least one side of the join is LAZY." ) ; } // first we just add the basic columns of this object
 foreach ( $ fms as $ fm ) { $ this -> AddFieldMap ( $ fm ) ; } // get the keymaps for the requested object
 $ kms = $ this -> _phreezer -> GetKeyMaps ( $ typename ) ; $ this -> _keymapcache [ $ typename ] = $ kms ; // save this to prevent infinite loop
 $ this -> _prevkeymap = $ typename ; // each keymap in this object that is eagerly loaded, we want to join into the query.
 // each of these tables, then might have eagerly loaded keymaps as well, so we'll use
 // recursion to eagerly load as much of the graph as is desired
 foreach ( $ kms as $ km ) { if ( $ km -> LoadType == KM_LOAD_EAGER || $ km -> LoadType == KM_LOAD_INNER ) { // check that we didn't eagerly join this already.
 // TODO: use aliases to support multiple eager joins to the same table
 if ( isset ( $ this -> Joins [ $ km -> ForeignObject . "_is_joined" ] ) ) { //print_r($typename);
 throw new Exception ( $ typename . "Map has multiple EAGER joins to `" . $ km -> ForeignObject . "` which is not yet supported by Phreeze." ) ; } $ ffms = $ this -> _phreezer -> GetFieldMaps ( $ km -> ForeignObject ) ; $ this -> RecurseFieldMaps ( $ km -> ForeignObject , $ ffms ) ; // lastly we need to add the join information for this foreign field map
 $ jointype = $ km -> LoadType == KM_LOAD_INNER ? "inner" : "left" ; foreach ( $ ffms as $ ffm ) { if ( ! isset ( $ this -> Joins [ $ ffm -> TableName ] ) ) { $ this -> Joins [ $ ffm -> TableName ] = " " . $ jointype . " join `" . $ ffm -> TableName . "` on `" . $ fms [ $ km -> KeyProperty ] -> TableName . "`.`" . $ fms [ $ km -> KeyProperty ] -> ColumnName . "` = `" . $ ffms [ $ km -> ForeignKeyProperty ] -> TableName . "`.`" . $ ffms [ $ km -> ForeignKeyProperty ] -> ColumnName . "`" ; } } // keep track of what we have eagerly joined already
 $ this -> Joins [ $ km -> ForeignObject . "_is_joined" ] = 1 ; } } }
Each Model that is to be included in this query is recursed, where all fields are added
to the queue and then looks for eager joins to recurse through

@param string $typename name of the Model object to be recursed
@param FieldMap $fm
Each Model that is to be included in this query is recursed where all fields are added to the queue and then looks for eager joins to recurse through