Attila/core/Entity.php
public function hasMany($sPrimaryKeyName, $sEntityJoinName, $sForeignKeyName, $sNamespaceEntity, array $aOptions = array())
	{
	    $this->_aJoins[$sEntityJoinName] = function($mParameters = null) use ($sPrimaryKeyName, $sEntityJoinName, $sForeignKeyName, $sNamespaceEntity)
	    {
	        if (!isset($this->$sEntityJoinName)) {
	        
	            $oOrm = new Orm;
	        
	            $oOrm->select(array('*'))
	                 ->from($sEntityJoinName);

	            if ($mParameters) { 
	                
	                $aWhere[$sForeignKeyName] = $mParameters; 
	            }
	            else { 
	                
	                $sMethodName = 'get_'.$sPrimaryKeyName;
	                $aWhere[$sForeignKeyName] = $this->$sMethodName(); 
	            }
	            	
	            	
	            $this->$sEntityJoinName = $oOrm->where($aWhere)
	                                           ->load(false, $sNamespaceEntity.'\\');
	        }
	        
	        return $this->$sEntityJoinName;
	    };
	    
	    if (isset($aOptions['foreignKey']) && !isset($this->_aForeignKey[$sEntityJoinName])) {
	    
	        $this->_aForeignKey[$sEntityJoinName] = array(
	            'primary_key' => $sPrimaryKeyName, 
	            'entity_join_name' => $sEntityJoinName, 
	            'foreign_key_name' => $sForeignKeyName,
	            'foreign_key_options' => $aOptions['foreignKey'],
	            'has_one' => 0
	        );
	    }
	}
public function hasMany($sPrimaryKeyName, $sEntityJoinName, $sForeignKeyName, $sNamespaceEntity, array $aOptions = array())
	{
	    $this->_aJoins[$sEntityJoinName] = function($mParameters = null) use ($sPrimaryKeyName, $sEntityJoinName, $sForeignKeyName, $sNamespaceEntity)
	    {
	        if (!isset($this->$sEntityJoinName)) {
	        
	            $oOrm = new Orm;
	        
	            $oOrm->select(array('*'))
	                 ->from($sEntityJoinName);

	            if ($mParameters) { 
	                
	                $aWhere[$sForeignKeyName] = $mParameters; 
	            }
	            else { 
	                
	                $sMethodName = 'get_'.$sPrimaryKeyName;
	                $aWhere[$sForeignKeyName] = $this->$sMethodName(); 
	            }
	            	
	            	
	            $this->$sEntityJoinName = $oOrm->where($aWhere)
	                                           ->load(false, $sNamespaceEntity.'\\');
	        }
	        
	        return $this->$sEntityJoinName;
	    };
	    
	    if (isset($aOptions['foreignKey']) && !isset($this->_aForeignKey[$sEntityJoinName])) {
	    
	        $this->_aForeignKey[$sEntityJoinName] = array(
	            'primary_key' => $sPrimaryKeyName, 
	            'entity_join_name' => $sEntityJoinName, 
	            'foreign_key_name' => $sForeignKeyName,
	            'foreign_key_options' => $aOptions['foreignKey'],
	            'has_one' => 0
	        );
	    }
	}
public function hasMany ( $ sPrimaryKeyName , $ sEntityJoinName , $ sForeignKeyName , $ sNamespaceEntity , array $ aOptions = array ( ) ) { $ this -> _aJoins [ $ sEntityJoinName ] = function ( $ mParameters = null ) use ( $ sPrimaryKeyName , $ sEntityJoinName , $ sForeignKeyName , $ sNamespaceEntity ) { if ( ! isset ( $ this -> $ sEntityJoinName ) ) { $ oOrm = new Orm ; $ oOrm -> select ( array ( '*' ) ) -> from ( $ sEntityJoinName ) ; if ( $ mParameters ) { $ aWhere [ $ sForeignKeyName ] = $ mParameters ; } else { $ sMethodName = 'get_' . $ sPrimaryKeyName ; $ aWhere [ $ sForeignKeyName ] = $ this -> $ sMethodName ( ) ; } $ this -> $ sEntityJoinName = $ oOrm -> where ( $ aWhere ) -> load ( false , $ sNamespaceEntity . '\\' ) ; } return $ this -> $ sEntityJoinName ; } ; if ( isset ( $ aOptions [ 'foreignKey' ] ) && ! isset ( $ this -> _aForeignKey [ $ sEntityJoinName ] ) ) { $ this -> _aForeignKey [ $ sEntityJoinName ] = array ( 'primary_key' => $ sPrimaryKeyName , 'entity_join_name' => $ sEntityJoinName , 'foreign_key_name' => $ sForeignKeyName , 'foreign_key_options' => $ aOptions [ 'foreignKey' ] , 'has_one' => 0 ) ; } }
create a join in one to many

@access public
@param string $sPrimaryKeyName
@param string $sEntityJoinName
@param string $sForeignKeyName
@param string $sNamespaceEntity
@param array $aOptions
@return array
create a join in one to many