2007-09-02 18:24:49 +04:00
|
|
|
<?php
|
|
|
|
class QueryTest_Category extends Doctrine_Record
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The depth of the category inside the tree.
|
|
|
|
* Non-persistent field.
|
|
|
|
*
|
|
|
|
* @var integer
|
|
|
|
*/
|
|
|
|
public $depth;
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-09-02 18:24:49 +04:00
|
|
|
/**
|
|
|
|
* 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'));
|
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-09-02 18:24:49 +04:00
|
|
|
/**
|
|
|
|
* Relations definition.
|
|
|
|
*/
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
$this->ownsMany('QueryTest_Category as subCategories', 'subCategories.parentCategoryId');
|
|
|
|
$this->hasOne('QueryTest_Category as rootCategory', 'QueryTest_Category.rootCategoryId');
|
|
|
|
$this->ownsMany('QueryTest_Board as boards', 'QueryTest_Board.categoryId');
|
|
|
|
}
|
|
|
|
}
|