2007-09-02 18:24:49 +04:00
|
|
|
<?php
|
2008-05-14 01:20:34 +04:00
|
|
|
class ForeignKeyTest extends Doctrine_Entity
|
2007-09-02 18:24:49 +04:00
|
|
|
{
|
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('name', 'string', null);
|
|
|
|
$class->setColumn('code', 'integer', 4);
|
|
|
|
$class->setColumn('content', 'string', 4000);
|
|
|
|
$class->setColumn('parent_id', 'integer');
|
2007-09-02 18:24:49 +04:00
|
|
|
|
2008-02-04 00:29:57 +03:00
|
|
|
$class->hasOne('ForeignKeyTest as Parent',
|
2007-09-02 18:24:49 +04:00
|
|
|
array('local' => 'parent_id',
|
|
|
|
'foreign' => 'id',
|
|
|
|
'onDelete' => 'CASCADE',
|
|
|
|
'onUpdate' => 'RESTRICT')
|
|
|
|
);
|
|
|
|
|
2008-02-04 00:29:57 +03:00
|
|
|
$class->hasMany('ForeignKeyTest as Children', array('local' => 'id', 'foreign' => 'parent_id'));
|
2007-09-02 18:24:49 +04:00
|
|
|
|
2008-02-04 00:29:57 +03:00
|
|
|
$class->setTableOption('type', 'INNODB');
|
2007-09-02 18:24:49 +04:00
|
|
|
}
|
|
|
|
}
|