RelationTest.php 723 Bytes
Newer Older
1
<?php
2
class RelationTest extends Doctrine_Entity 
3
{
4
    public static function initMetadata($class) 
5
    {
romanb's avatar
romanb committed
6
        $class->setInheritanceType(Doctrine::INHERITANCE_TYPE_TABLE_PER_CLASS);
7 8
        $class->setColumn('name', 'string', 200);
        $class->setColumn('parent_id', 'integer');
9 10 11
    }
}

12 13
class RelationTestChild extends RelationTest 
{
14
    public static function initMetadata($class) 
15
    {
16
        $class->hasOne('RelationTest as Parent', array(
17 18 19 20
            'local' => 'parent_id',
            'foreign' => 'id',
            'onDelete' => 'CASCADE',
        ));
21
        $class->hasMany('RelationTestChild as Children', array(
22 23 24
            'local' => 'id',
            'foreign' => 'parent_id',
        ));
25 26
    }
}