Attila/lib/Entity.php
public static function autoLoadEntity($sEntity, array $aSql, $sPrefix = '', $bAddOnStdClass = false, $sEntityNamespace = null) 
	{
		if ($sEntity === '') { return; }

		if ($sEntityNamespace !== null) {
			
			self::setEntityNamespace($sEntityNamespace);
		}
			
		$sEntityName = self::$_sEntityNamespace.$sEntity;

		if (!class_exists($sEntityName)) { return; }

		$oEntityCall = new $sEntityName;
		$oReflectionClass = new \ReflectionClass($sEntityName);
		$oReflectionProperties = $oReflectionClass->getProperties();

		foreach ($oReflectionProperties as $aProperty) {

			if (preg_match('/@map ([a-zA-Z_]+)/', $aProperty->getDocComment(), $aMatch)) {

				$sEntitieRealName = $aMatch[1];
			}
			else {

				$sEntitieRealName = $aProperty->getName();
			}

			if (method_exists($oEntityCall, 'set_'.$aProperty->getName())) {

				if (isset($aSql[$sPrefix.$sEntitieRealName])) {

					$sMethodName = 'set_'.$aProperty->getName();
					$oEntityCall->$sMethodName($aSql[$sPrefix.$sEntitieRealName]);
				}
			}
		}

		if ($bAddOnStdClass === true) {

			foreach ($aSql as $sKey => $asField) {

				if (preg_match('/^\.[^.]+$/', $sKey)) {

					$sParameterName = str_replace('.', '', $sKey);
					$oEntityCall->$sParameterName = $aSql[$sKey];
				}
			}
		}

		return $oEntityCall;
	}
public static function autoLoadEntity($sEntity, array $aSql, $sPrefix = '', $bAddOnStdClass = false, $sEntityNamespace = null) 
	{
		if ($sEntity === '') { return; }

		if ($sEntityNamespace !== null) {
			
			self::setEntityNamespace($sEntityNamespace);
		}
			
		$sEntityName = self::$_sEntityNamespace.$sEntity;

		if (!class_exists($sEntityName)) { return; }

		$oEntityCall = new $sEntityName;
		$oReflectionClass = new \ReflectionClass($sEntityName);
		$oReflectionProperties = $oReflectionClass->getProperties();

		foreach ($oReflectionProperties as $aProperty) {

			if (preg_match('/@map ([a-zA-Z_]+)/', $aProperty->getDocComment(), $aMatch)) {

				$sEntitieRealName = $aMatch[1];
			}
			else {

				$sEntitieRealName = $aProperty->getName();
			}

			if (method_exists($oEntityCall, 'set_'.$aProperty->getName())) {

				if (isset($aSql[$sPrefix.$sEntitieRealName])) {

					$sMethodName = 'set_'.$aProperty->getName();
					$oEntityCall->$sMethodName($aSql[$sPrefix.$sEntitieRealName]);
				}
			}
		}

		if ($bAddOnStdClass === true) {

			foreach ($aSql as $sKey => $asField) {

				if (preg_match('/^\.[^.]+$/', $sKey)) {

					$sParameterName = str_replace('.', '', $sKey);
					$oEntityCall->$sParameterName = $aSql[$sKey];
				}
			}
		}

		return $oEntityCall;
	}
public static function autoLoadEntity ( $ sEntity , array $ aSql , $ sPrefix = '' , $ bAddOnStdClass = false , $ sEntityNamespace = null ) { if ( $ sEntity === '' ) { return ; } if ( $ sEntityNamespace !== null ) { self :: setEntityNamespace ( $ sEntityNamespace ) ; } $ sEntityName = self :: $ _sEntityNamespace . $ sEntity ; if ( ! class_exists ( $ sEntityName ) ) { return ; } $ oEntityCall = new $ sEntityName ; $ oReflectionClass = new \ ReflectionClass ( $ sEntityName ) ; $ oReflectionProperties = $ oReflectionClass -> getProperties ( ) ; foreach ( $ oReflectionProperties as $ aProperty ) { if ( preg_match ( '/@map ([a-zA-Z_]+)/' , $ aProperty -> getDocComment ( ) , $ aMatch ) ) { $ sEntitieRealName = $ aMatch [ 1 ] ; } else { $ sEntitieRealName = $ aProperty -> getName ( ) ; } if ( method_exists ( $ oEntityCall , 'set_' . $ aProperty -> getName ( ) ) ) { if ( isset ( $ aSql [ $ sPrefix . $ sEntitieRealName ] ) ) { $ sMethodName = 'set_' . $ aProperty -> getName ( ) ; $ oEntityCall -> $ sMethodName ( $ aSql [ $ sPrefix . $ sEntitieRealName ] ) ; } } } if ( $ bAddOnStdClass === true ) { foreach ( $ aSql as $ sKey => $ asField ) { if ( preg_match ( '/^\.[^.]+$/' , $ sKey ) ) { $ sParameterName = str_replace ( '.' , '' , $ sKey ) ; $ oEntityCall -> $ sParameterName = $ aSql [ $ sKey ] ; } } } return $ oEntityCall ; }
auto load the domain by a sql return

exemple :
autoLoadDomain('GenericUpdate', array('Generic_Message' => 'OK', 'Generic_Result' => 1), 'Generic');

A domain is an container of properties, getters and setters without crud methods (just a container)

You could give an object in entry!!!

@access public
@param  string $sEntity domain that we want load
@param  array $aSql results in array by the sql array('id' => 1, 'title' => 'super');
@param  string $sPrefix prefixe for the sql returns
@param  bool $bAddOnStdClass add the parameter when there arent method of entity
@param  string $sEntityNamespace change the default portal for the entity
@return object
auto load the domain by a sql return