private function GetTableJoinSQL($criteria)
	{
		$sql = "";
		
		$tablenames = array_keys($this->Tables);
		
		if (count($tablenames) > 1)
		{
			// we're selecting from multiple tables so we have to do an outer join
			$sql .= " from `" . $tablenames[0] . "`";
				
			// WARNING: if tables are being joined in the incorrect order, it is likely
			// caused by a query that goes across more than one foreign relationship.
			// you can force tables to be joined in a specific order by adding a field
			// reference in the outermost Phreezable FieldMap.  QueryBuilder will
			// include tables in whatever order they are references, so you can control
			// this by simply adding in referenced to foreign field in the order you want
			// the tables to be joined
			//for ($i = count($tablenames) -1; $i > 0 ; $i--) // this iterates backwards
			for ($i = 1; $i < count($tablenames); $i++)      // this iterates forwards
			{
				try
				{
					$sql .= $this->Joins[$tablenames[$i]];
				}
				catch (Exception $ex)
				{
					// if 'undefined index' occurs here, there is likely a foreign field in the fieldmap that does not have it's related keymap set to KM_LOAD_EAGER
					throw new Exception("An invalid join was attempted from table '" . $tablenames[$i] 
						. "'. Please verify that the KeyMap fetching strategy for table '" . $tablenames[0]
						. "' has been properly configured.");
				}
			}
		}
		else
		{
			// we are only selecting from one table
			// (LL) added backticks here
			$sql .= " from `" . $tablenames[0] . "` ";
		}
		
		return $sql;
	}
private function GetTableJoinSQL($criteria)
	{
		$sql = "";
		
		$tablenames = array_keys($this->Tables);
		
		if (count($tablenames) > 1)
		{
			// we're selecting from multiple tables so we have to do an outer join
			$sql .= " from `" . $tablenames[0] . "`";
				
			// WARNING: if tables are being joined in the incorrect order, it is likely
			// caused by a query that goes across more than one foreign relationship.
			// you can force tables to be joined in a specific order by adding a field
			// reference in the outermost Phreezable FieldMap.  QueryBuilder will
			// include tables in whatever order they are references, so you can control
			// this by simply adding in referenced to foreign field in the order you want
			// the tables to be joined
			//for ($i = count($tablenames) -1; $i > 0 ; $i--) // this iterates backwards
			for ($i = 1; $i < count($tablenames); $i++)      // this iterates forwards
			{
				try
				{
					$sql .= $this->Joins[$tablenames[$i]];
				}
				catch (Exception $ex)
				{
					// if 'undefined index' occurs here, there is likely a foreign field in the fieldmap that does not have it's related keymap set to KM_LOAD_EAGER
					throw new Exception("An invalid join was attempted from table '" . $tablenames[$i] 
						. "'. Please verify that the KeyMap fetching strategy for table '" . $tablenames[0]
						. "' has been properly configured.");
				}
			}
		}
		else
		{
			// we are only selecting from one table
			// (LL) added backticks here
			$sql .= " from `" . $tablenames[0] . "` ";
		}
		
		return $sql;
	}
private function GetTableJoinSQL ( $ criteria ) { $ sql = "" ; $ tablenames = array_keys ( $ this -> Tables ) ; if ( count ( $ tablenames ) > 1 ) { // we're selecting from multiple tables so we have to do an outer join
 $ sql .= " from `" . $ tablenames [ 0 ] . "`" ; // WARNING: if tables are being joined in the incorrect order, it is likely
 // caused by a query that goes across more than one foreign relationship.
 // you can force tables to be joined in a specific order by adding a field
 // reference in the outermost Phreezable FieldMap.  QueryBuilder will
 // include tables in whatever order they are references, so you can control
 // this by simply adding in referenced to foreign field in the order you want
 // the tables to be joined
 //for ($i = count($tablenames) -1; $i > 0 ; $i--) // this iterates backwards
 for ( $ i = 1 ; $ i < count ( $ tablenames ) ; $ i ++ ) // this iterates forwards
 { try { $ sql .= $ this -> Joins [ $ tablenames [ $ i ] ] ; } catch ( Exception $ ex ) { // if 'undefined index' occurs here, there is likely a foreign field in the fieldmap that does not have it's related keymap set to KM_LOAD_EAGER
 throw new Exception ( "An invalid join was attempted from table '" . $ tablenames [ $ i ] . "'. Please verify that the KeyMap fetching strategy for table '" . $ tablenames [ 0 ] . "' has been properly configured." ) ; } } } else { // we are only selecting from one table
 // (LL) added backticks here
 $ sql .= " from `" . $ tablenames [ 0 ] . "` " ; } return $ sql ; }
Determines what tables need to be included in the query
based on the mapping
@param Criteria $criteria
@return string "from" sql
Determines what tables need to be included in the query based on the mapping