1
0
mirror of synced 2024-12-14 07:06:04 +03:00
doctrine2/tests/models/forum/ForumUser.php

57 lines
1.7 KiB
PHP
Raw Normal View History

2008-02-11 20:08:22 +03:00
<?php
2009-01-04 19:15:32 +03:00
#namespace Doctrine\Tests\Models\Forum;
#use Doctrine\ORM\Entity;
class ForumUser
2008-02-11 20:08:22 +03:00
{
public $id;
public $username;
public $avatar;
public static function initMetadata($mapping)
2008-02-11 20:08:22 +03:00
{
/*$mapping->setClassMetadata(array(
'doctrine.inheritanceType' => 'joined',
'doctrine.discriminatorColumn' => 'dtype',
'doctrine.discriminatorMap' => array('user' => 'ForumUser', 'admin' => 'ForumAdministrator'),
'doctrine.subclasses' => array('ForumAdministrator')
));
$mapping->setFieldMetadata('id', array(
'doctrine.type' => 'integer',
'doctrine.id' => true,
'doctrine.idGenerator' => 'auto'
));*/
2008-02-11 20:08:22 +03:00
// inheritance mapping
$mapping->setInheritanceType('joined', array(
2008-02-11 20:08:22 +03:00
'discriminatorColumn' => 'dtype',
'discriminatorMap' => array(
'user' => 'ForumUser',
'admin' => 'ForumAdministrator')
2008-02-11 20:08:22 +03:00
));
2008-03-23 14:30:29 +03:00
// register subclasses
$mapping->setSubclasses(array('ForumAdministrator'));
2008-03-23 14:30:29 +03:00
// column-to-field mapping
$mapping->mapField(array(
'fieldName' => 'id',
'type' => 'integer',
'id' => true,
2008-07-27 23:38:56 +04:00
'idGenerator' => 'auto'
));
$mapping->mapField(array(
'fieldName' => 'username',
'type' => 'string',
'length' => 50
));
2008-08-16 23:40:59 +04:00
$mapping->mapOneToOne(array(
'fieldName' => 'avatar',
'targetEntity' => 'ForumAvatar',
'joinColumns' => array('avatar_id' => 'id'),
'cascade' => array('save')
));
2008-02-11 20:08:22 +03:00
}
}