protected static function addRelationOneToMany($sourceField, $classRelation, $targetField, $aliasRelation = '')
    {
        // test is related class is a PicORM model
        if (!class_exists($classRelation) || !new $classRelation() instanceof Model) {
            throw new Exception("Class " . $classRelation . " doesn't exists or is not subclass of PicORM\Model");
        }

        // create relation id with normalized classRelation name
        $idRelation = self :: formatClassnameToRelationName($classRelation);

        // override the relation's id if an alias is present
        if (!empty($aliasRelation)) {
            $idRelation = strtolower($aliasRelation);
        }

        // store new relation in model
        static::$_relations[$idRelation] = array(
            'typeRelation'  => self::ONE_TO_MANY,
            'classRelation' => $classRelation,
            'sourceField'   => $sourceField,
            'targetField'   => $targetField,
        );
    }
protected static function addRelationOneToMany($sourceField, $classRelation, $targetField, $aliasRelation = '')
    {
        // test is related class is a PicORM model
        if (!class_exists($classRelation) || !new $classRelation() instanceof Model) {
            throw new Exception("Class " . $classRelation . " doesn't exists or is not subclass of PicORM\Model");
        }

        // create relation id with normalized classRelation name
        $idRelation = self :: formatClassnameToRelationName($classRelation);

        // override the relation's id if an alias is present
        if (!empty($aliasRelation)) {
            $idRelation = strtolower($aliasRelation);
        }

        // store new relation in model
        static::$_relations[$idRelation] = array(
            'typeRelation'  => self::ONE_TO_MANY,
            'classRelation' => $classRelation,
            'sourceField'   => $sourceField,
            'targetField'   => $targetField,
        );
    }
protected static function addRelationOneToMany ( $ sourceField , $ classRelation , $ targetField , $ aliasRelation = '' ) { // test is related class is a PicORM model if ( ! class_exists ( $ classRelation ) || ! new $ classRelation ( ) instanceof Model ) { throw new Exception ( "Class " . $ classRelation . " doesn't exists or is not subclass of PicORM\Model" ) ; } // create relation id with normalized classRelation name $ idRelation = self :: formatClassnameToRelationName ( $ classRelation ) ; // override the relation's id if an alias is present if ( ! empty ( $ aliasRelation ) ) { $ idRelation = strtolower ( $ aliasRelation ) ; } // store new relation in model static :: $ _relations [ $ idRelation ] = array ( 'typeRelation' => self :: ONE_TO_MANY , 'classRelation' => $ classRelation , 'sourceField' => $ sourceField , 'targetField' => $ targetField , ) ; }
Add a OneToMany relation

@param        $sourceField   - model source field
@param        $classRelation - relation model classname
@param        $targetField   - related model target field
@param string $aliasRelation - override relation auto naming className with an alias

@throws Exception
Add a OneToMany relation