2010-03-17 01:41:09 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
|
|
|
|
|
|
|
$metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE);
|
|
|
|
$metadata->setPrimaryTable(array(
|
|
|
|
'name' => 'cms_users',
|
|
|
|
));
|
|
|
|
$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT);
|
|
|
|
$metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist');
|
|
|
|
$metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', 'prePersist');
|
|
|
|
$metadata->addLifecycleCallback('doStuffOnPostPersist', 'postPersist');
|
2011-03-07 00:45:09 +03:00
|
|
|
$metadata->addNamedQuery(array(
|
|
|
|
'name' => 'all',
|
|
|
|
'query' => 'SELECT u FROM __CLASS__ u'
|
|
|
|
));
|
2010-03-17 01:41:09 +03:00
|
|
|
$metadata->mapField(array(
|
|
|
|
'id' => true,
|
|
|
|
'fieldName' => 'id',
|
|
|
|
'type' => 'integer',
|
|
|
|
'columnName' => 'id',
|
|
|
|
));
|
|
|
|
$metadata->mapField(array(
|
|
|
|
'fieldName' => 'name',
|
|
|
|
'type' => 'string',
|
|
|
|
'length' => 50,
|
|
|
|
'unique' => true,
|
|
|
|
'nullable' => true,
|
|
|
|
'columnName' => 'name',
|
|
|
|
));
|
|
|
|
$metadata->mapField(array(
|
|
|
|
'fieldName' => 'email',
|
|
|
|
'type' => 'string',
|
|
|
|
'columnName' => 'user_email',
|
|
|
|
'columnDefinition' => 'CHAR(32) NOT NULL',
|
|
|
|
));
|
|
|
|
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
|
|
|
|
$metadata->mapOneToOne(array(
|
|
|
|
'fieldName' => 'address',
|
|
|
|
'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Address',
|
|
|
|
'cascade' =>
|
|
|
|
array(
|
|
|
|
0 => 'remove',
|
|
|
|
),
|
|
|
|
'mappedBy' => NULL,
|
2010-04-10 02:00:36 +04:00
|
|
|
'inversedBy' => 'user',
|
2010-03-17 01:41:09 +03:00
|
|
|
'joinColumns' =>
|
|
|
|
array(
|
|
|
|
0 =>
|
|
|
|
array(
|
|
|
|
'name' => 'address_id',
|
|
|
|
'referencedColumnName' => 'id',
|
2010-03-17 17:20:18 +03:00
|
|
|
'onDelete' => 'CASCADE',
|
2010-03-17 01:41:09 +03:00
|
|
|
),
|
|
|
|
),
|
|
|
|
'orphanRemoval' => false,
|
|
|
|
));
|
|
|
|
$metadata->mapOneToMany(array(
|
|
|
|
'fieldName' => 'phonenumbers',
|
|
|
|
'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Phonenumber',
|
|
|
|
'cascade' =>
|
|
|
|
array(
|
|
|
|
1 => 'persist',
|
|
|
|
),
|
|
|
|
'mappedBy' => 'user',
|
|
|
|
'orphanRemoval' => false,
|
|
|
|
'orderBy' =>
|
|
|
|
array(
|
|
|
|
'number' => 'ASC',
|
|
|
|
),
|
|
|
|
));
|
|
|
|
$metadata->mapManyToMany(array(
|
|
|
|
'fieldName' => 'groups',
|
|
|
|
'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Group',
|
|
|
|
'cascade' =>
|
|
|
|
array(
|
|
|
|
0 => 'remove',
|
|
|
|
1 => 'persist',
|
|
|
|
2 => 'refresh',
|
|
|
|
3 => 'merge',
|
|
|
|
4 => 'detach',
|
|
|
|
),
|
|
|
|
'mappedBy' => NULL,
|
|
|
|
'joinTable' =>
|
|
|
|
array(
|
|
|
|
'name' => 'cms_users_groups',
|
|
|
|
'joinColumns' =>
|
|
|
|
array(
|
|
|
|
0 =>
|
|
|
|
array(
|
|
|
|
'name' => 'user_id',
|
|
|
|
'referencedColumnName' => 'id',
|
|
|
|
'unique' => false,
|
|
|
|
'nullable' => false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'inverseJoinColumns' =>
|
|
|
|
array(
|
|
|
|
0 =>
|
|
|
|
array(
|
|
|
|
'name' => 'group_id',
|
|
|
|
'referencedColumnName' => 'id',
|
|
|
|
'columnDefinition' => 'INT NULL',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'orderBy' => NULL,
|
2010-04-28 22:27:53 +04:00
|
|
|
));
|
|
|
|
$metadata->table['uniqueConstraints'] = array(
|
|
|
|
'search_idx' => array('columns' => array('name', 'user_email')),
|
2010-05-01 05:28:18 +04:00
|
|
|
);
|
2010-06-14 00:59:56 +04:00
|
|
|
$metadata->table['indexes'] = array(
|
|
|
|
'name_idx' => array('columns' => array('name')), 0 => array('columns' => array('user_email'))
|
|
|
|
);
|
2010-05-01 05:28:18 +04:00
|
|
|
$metadata->setSequenceGeneratorDefinition(array(
|
|
|
|
'sequenceName' => 'tablename_seq',
|
|
|
|
'allocationSize' => 100,
|
|
|
|
'initialValue' => 1,
|
|
|
|
));
|