Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Doctrine\Tests\ORM\Mapping;
- use Doctrine\ORM\Mapping\ClassMetadata,
- Doctrine\ORM\Mapping\ClassMetadataInfo;
- class User
- {
- protected $id;
- protected $name;
- protected $email;
- protected $groups;
- }
- $metadata = new ClassMetadata('Doctrine\Tests\ORM\Mapping\User');
- $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE);
- $metadata->setPrimaryTable(array(
- 'name' => 'cms_users',
- ));
- $metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT);
- $metadata->addNamedQuery(array(
- 'name' => 'all',
- 'query' => 'SELECT u FROM __CLASS__ u'
- ));
- $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->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,
- ));
- $metadata->table['uniqueConstraints'] = array(
- 'search_idx' => array('columns' => array('name', 'user_email')),
- );
- $metadata->table['indexes'] = array(
- 'name_idx' => array('columns' => array('name')), 0 => array('columns' => array('user_email'))
- );
- $metadata->setSequenceGeneratorDefinition(array(
- 'sequenceName' => 'tablename_seq',
- 'allocationSize' => 100,
- 'initialValue' => 1,
- ));
Add Comment
Please, Sign In to add comment