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.
|
|
|
|
*/
|
2008-02-04 00:29:57 +03:00
|
|
|
public static function initMetadata($class)
|
2007-09-02 18:24:49 +04:00
|
|
|
{
|
2008-02-04 00:29:57 +03:00
|
|
|
$class->setColumn('rootCategoryId as rootCategoryId', 'integer', 4,
|
2007-09-02 18:24:49 +04:00
|
|
|
array('default' => 0));
|
2008-02-04 00:29:57 +03:00
|
|
|
$class->setColumn('parentCategoryId as parentCategoryId', 'integer', 4,
|
2007-09-02 18:24:49 +04:00
|
|
|
array('notnull', 'default' => 0));
|
2008-02-04 00:29:57 +03:00
|
|
|
$class->setColumn('name as name', 'string', 50,
|
2007-09-02 18:24:49 +04:00
|
|
|
array('notnull', 'unique'));
|
2008-02-04 00:29:57 +03:00
|
|
|
$class->setColumn('position as position', 'integer', 4,
|
2007-09-02 18:24:49 +04:00
|
|
|
array('default' => 0, 'notnull'));
|
2008-02-04 00:29:57 +03:00
|
|
|
|
|
|
|
$class->hasMany('QueryTest_Category as subCategories', array('local' => 'id', 'foreign' => 'parentCategoryId'));
|
|
|
|
$class->hasOne('QueryTest_Category as rootCategory', array('local' => 'rootCategoryId', 'foreign' => 'id'));
|
|
|
|
$class->hasMany('QueryTest_Board as boards', array('local' => 'id', 'foreign' => 'categoryId'));
|
2007-09-02 18:24:49 +04:00
|
|
|
}
|
|
|
|
}
|