final public function getRelated($relatedProperty) {
		
		$cacheName = $relatedProperty . 'RelatedObject';
		
		// object exists in cache, return it
		if ($this->issetCache($cacheName)) {
			return $this->getCache($cacheName);
		}
		
		// get table foreign-keys
		$foreignKeys = $this->db->getForeignKeys(static::TABLE_NAME);
		
		// get field name by mapped property
		$relatedField = $this->getMappedField($relatedProperty);
		
		// the table referenced by fk
		$referencedTable = NULL;
			
		// search the fk-table
		foreach ($foreignKeys as $fk) {
			if ($fk->COLUMN_NAME == $relatedField) {
				$referencedTable  = $fk->REFERENCED_TABLE_NAME;
				$referencedColumn = $fk->REFERENCED_COLUMN_NAME;
				break;
			}
		}
		
		// if not table is referenced, raise an error
		if (!$referencedTable) {
			$this->addError('Property ' . $relatedProperty . ' has not a foreign-key mapped into DB');
			return NULL;
		}
		
		// class that maps the referenced table
		$relatedClass = NULL;
		$loadedClasses = \get_declared_classes();
		
		// search in loaded classes
		foreach ($loadedClasses as $c) {
			if (is_subclass_of($c, 'Pair\ActiveRecord') and property_exists($c, 'TABLE_NAME') and $c::TABLE_NAME == $referencedTable) {
				$relatedClass = $c;
				break;
			}
		}
			
		// class cannot be found
		if (!$relatedClass) {
			
			// if not found, search in the whole application (FIXME encapsulation violated here...)
			$classes = Utilities::getActiveRecordClasses();
			
			// search for required one
			foreach ($classes as $class => $opts) {
				if ($opts['tableName'] == $referencedTable) {
					include_once($opts['folder'] . '/' . $opts['file']);
					$relatedClass = $class;
					break;
				}
			}
			
		}
		
		// class cannot be found
		if (!$relatedClass) {
			$this->addError('Table ' . $referencedTable . ' has not any Pair-class mapping');
			return NULL;
		}
		
		// create the new wanted Pair object
		$obj = new $relatedClass($this->$relatedProperty);
		
		// if loaded, return it otherwise NULL
		$ret = ($obj->isLoaded() ? $obj : NULL);
		
		// related object is being registered in cache of this object
		$this->setCache($cacheName, $ret);
		
		return $ret;
		
	}
final public function getRelated($relatedProperty) {
		
		$cacheName = $relatedProperty . 'RelatedObject';
		
		// object exists in cache, return it
		if ($this->issetCache($cacheName)) {
			return $this->getCache($cacheName);
		}
		
		// get table foreign-keys
		$foreignKeys = $this->db->getForeignKeys(static::TABLE_NAME);
		
		// get field name by mapped property
		$relatedField = $this->getMappedField($relatedProperty);
		
		// the table referenced by fk
		$referencedTable = NULL;
			
		// search the fk-table
		foreach ($foreignKeys as $fk) {
			if ($fk->COLUMN_NAME == $relatedField) {
				$referencedTable  = $fk->REFERENCED_TABLE_NAME;
				$referencedColumn = $fk->REFERENCED_COLUMN_NAME;
				break;
			}
		}
		
		// if not table is referenced, raise an error
		if (!$referencedTable) {
			$this->addError('Property ' . $relatedProperty . ' has not a foreign-key mapped into DB');
			return NULL;
		}
		
		// class that maps the referenced table
		$relatedClass = NULL;
		$loadedClasses = \get_declared_classes();
		
		// search in loaded classes
		foreach ($loadedClasses as $c) {
			if (is_subclass_of($c, 'Pair\ActiveRecord') and property_exists($c, 'TABLE_NAME') and $c::TABLE_NAME == $referencedTable) {
				$relatedClass = $c;
				break;
			}
		}
			
		// class cannot be found
		if (!$relatedClass) {
			
			// if not found, search in the whole application (FIXME encapsulation violated here...)
			$classes = Utilities::getActiveRecordClasses();
			
			// search for required one
			foreach ($classes as $class => $opts) {
				if ($opts['tableName'] == $referencedTable) {
					include_once($opts['folder'] . '/' . $opts['file']);
					$relatedClass = $class;
					break;
				}
			}
			
		}
		
		// class cannot be found
		if (!$relatedClass) {
			$this->addError('Table ' . $referencedTable . ' has not any Pair-class mapping');
			return NULL;
		}
		
		// create the new wanted Pair object
		$obj = new $relatedClass($this->$relatedProperty);
		
		// if loaded, return it otherwise NULL
		$ret = ($obj->isLoaded() ? $obj : NULL);
		
		// related object is being registered in cache of this object
		$this->setCache($cacheName, $ret);
		
		return $ret;
		
	}
final public function getRelated ( $ relatedProperty ) { $ cacheName = $ relatedProperty . 'RelatedObject' ; // object exists in cache, return it if ( $ this -> issetCache ( $ cacheName ) ) { return $ this -> getCache ( $ cacheName ) ; } // get table foreign-keys $ foreignKeys = $ this -> db -> getForeignKeys ( static :: TABLE_NAME ) ; // get field name by mapped property $ relatedField = $ this -> getMappedField ( $ relatedProperty ) ; // the table referenced by fk $ referencedTable = NULL ; // search the fk-table foreach ( $ foreignKeys as $ fk ) { if ( $ fk -> COLUMN_NAME == $ relatedField ) { $ referencedTable = $ fk -> REFERENCED_TABLE_NAME ; $ referencedColumn = $ fk -> REFERENCED_COLUMN_NAME ; break ; } } // if not table is referenced, raise an error if ( ! $ referencedTable ) { $ this -> addError ( 'Property ' . $ relatedProperty . ' has not a foreign-key mapped into DB' ) ; return NULL ; } // class that maps the referenced table $ relatedClass = NULL ; $ loadedClasses = \ get_declared_classes ( ) ; // search in loaded classes foreach ( $ loadedClasses as $ c ) { if ( is_subclass_of ( $ c , 'Pair\ActiveRecord' ) and property_exists ( $ c , 'TABLE_NAME' ) and $ c :: TABLE_NAME == $ referencedTable ) { $ relatedClass = $ c ; break ; } } // class cannot be found if ( ! $ relatedClass ) { // if not found, search in the whole application (FIXME encapsulation violated here...) $ classes = Utilities :: getActiveRecordClasses ( ) ; // search for required one foreach ( $ classes as $ class => $ opts ) { if ( $ opts [ 'tableName' ] == $ referencedTable ) { include_once ( $ opts [ 'folder' ] . '/' . $ opts [ 'file' ] ) ; $ relatedClass = $ class ; break ; } } } // class cannot be found if ( ! $ relatedClass ) { $ this -> addError ( 'Table ' . $ referencedTable . ' has not any Pair-class mapping' ) ; return NULL ; } // create the new wanted Pair object $ obj = new $ relatedClass ( $ this -> $ relatedProperty ) ; // if loaded, return it otherwise NULL $ ret = ( $ obj -> isLoaded ( ) ? $ obj : NULL ) ; // related object is being registered in cache of this object $ this -> setCache ( $ cacheName , $ ret ) ; return $ ret ; }
Return the Pair\ActiveRecord inherited object related to this by a ForeignKey in DB-table. Cached method.

@param	string	Related property name.

@return	multitype|NULL
Return the Pair \ ActiveRecord inherited object related to this by a ForeignKey in DB - table . Cached method .