QueryTest_Category.php 1.11 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
<?php
class QueryTest_Category extends Doctrine_Record
{    
    /**
     * The depth of the category inside the tree.
     * Non-persistent field. 
     * 
     * @var integer
     */
    public $depth;
11

12 13 14 15 16 17 18 19 20 21 22 23 24 25
    /**
     * Table definition.
     */
    public function setTableDefinition()
    {        
        $this->hasColumn('rootCategoryId as rootCategoryId', 'integer', 4,
                array('default' => 0));
        $this->hasColumn('parentCategoryId as parentCategoryId', 'integer', 4,
                array('notnull', 'default' => 0));
        $this->hasColumn('name as name', 'string', 50,
                array('notnull', 'unique'));
        $this->hasColumn('position as position', 'integer', 4,
                array('default' => 0, 'notnull'));
    }
26

27 28 29 30 31
    /**
     * Relations definition.
     */
    public function setUp()
    {
jwage's avatar
jwage committed
32
        $this->hasMany('QueryTest_Category as subCategories', 'subCategories.parentCategoryId');
33
        $this->hasOne('QueryTest_Category as rootCategory', 'QueryTest_Category.rootCategoryId');
jwage's avatar
jwage committed
34
        $this->hasMany('QueryTest_Board as boards', 'QueryTest_Board.categoryId');
35 36
    }
}