当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMetadataInfo::setPrimaryTable方法代码示例

本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadataInfo::setPrimaryTable方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadataInfo::setPrimaryTable方法的具体用法?PHP ClassMetadataInfo::setPrimaryTable怎么用?PHP ClassMetadataInfo::setPrimaryTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\Mapping\ClassMetadataInfo的用法示例。


在下文中一共展示了ClassMetadataInfo::setPrimaryTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate

 /**
  * @param BundleInterface $bundle         The bundle
  * @param string          $entity         The entity name
  * @param string          $format         The format
  * @param array           $fields         The fields
  * @param boolean         $withRepository With repository
  * @param string          $prefix         A prefix
  *
  * @throws \RuntimeException
  */
 public function generate(BundleInterface $bundle, $entity, $format, array $fields, $withRepository, $prefix)
 {
     // configure the bundle (needed if the bundle does not contain any Entities yet)
     $config = $this->registry->getManager(null)->getConfiguration();
     $config->setEntityNamespaces(array_merge(array($bundle->getName() => $bundle->getNamespace() . '\\Entity'), $config->getEntityNamespaces()));
     $entityClass = $this->registry->getAliasNamespace($bundle->getName()) . '\\' . $entity;
     $entityPath = $bundle->getPath() . '/Entity/' . str_replace('\\', '/', $entity) . '.php';
     if (file_exists($entityPath)) {
         throw new \RuntimeException(sprintf('Entity "%s" already exists.', $entityClass));
     }
     $class = new ClassMetadataInfo($entityClass);
     if ($withRepository) {
         $entityClass = preg_replace('/\\\\Entity\\\\/', '\\Repository\\', $entityClass, 1);
         $class->customRepositoryClassName = $entityClass . 'Repository';
     }
     foreach ($fields as $field) {
         $class->mapField($field);
     }
     $class->setPrimaryTable(array('name' => $prefix . $this->getTableNameFromEntityName($entity)));
     $entityGenerator = $this->getEntityGenerator();
     $entityCode = $entityGenerator->generateEntityClass($class);
     $mappingPath = $mappingCode = false;
     $this->filesystem->mkdir(dirname($entityPath));
     file_put_contents($entityPath, $entityCode);
     if ($mappingPath) {
         $this->filesystem->mkdir(dirname($mappingPath));
         file_put_contents($mappingPath, $mappingCode);
     }
     if ($withRepository) {
         $path = $bundle->getPath() . str_repeat('/..', substr_count(get_class($bundle), '\\'));
         $this->getRepositoryGenerator()->writeEntityRepositoryClass($class->customRepositoryClassName, $path);
     }
     $this->addGeneratedEntityClassLoader($entityClass, $entityPath);
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:44,代码来源:DoctrineEntityGenerator.php

示例2: generate

 /**
  * @param BundleInterface $bundle
  * @param string          $entity
  * @param string          $format
  * @param array           $fields
  *
  * @return EntityGeneratorResult
  *
  * @throws \Doctrine\ORM\Tools\Export\ExportException
  */
 public function generate(BundleInterface $bundle, $entity, $format, array $fields)
 {
     // configure the bundle (needed if the bundle does not contain any Entities yet)
     $config = $this->registry->getManager(null)->getConfiguration();
     $config->setEntityNamespaces(array_merge(array($bundle->getName() => $bundle->getNamespace() . '\\Entity'), $config->getEntityNamespaces()));
     $entityClass = $this->registry->getAliasNamespace($bundle->getName()) . '\\' . $entity;
     $entityPath = $bundle->getPath() . '/Entity/' . str_replace('\\', '/', $entity) . '.php';
     if (file_exists($entityPath)) {
         throw new \RuntimeException(sprintf('Entity "%s" already exists.', $entityClass));
     }
     $class = new ClassMetadataInfo($entityClass);
     $class->customRepositoryClassName = str_replace('\\Entity\\', '\\Repository\\', $entityClass) . 'Repository';
     $class->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
     $class->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
     foreach ($fields as $field) {
         $class->mapField($field);
     }
     $entityGenerator = $this->getEntityGenerator();
     if ('annotation' === $format) {
         $entityGenerator->setGenerateAnnotations(true);
         $class->setPrimaryTable(array('name' => Inflector::tableize($entity)));
         $entityCode = $entityGenerator->generateEntityClass($class);
         $mappingPath = $mappingCode = false;
     } else {
         $cme = new ClassMetadataExporter();
         $exporter = $cme->getExporter('yml' == $format ? 'yaml' : $format);
         $mappingPath = $bundle->getPath() . '/Resources/config/doctrine/' . str_replace('\\', '.', $entity) . '.orm.' . $format;
         if (file_exists($mappingPath)) {
             throw new \RuntimeException(sprintf('Cannot generate entity when mapping "%s" already exists.', $mappingPath));
         }
         $mappingCode = $exporter->exportClassMetadata($class);
         $entityGenerator->setGenerateAnnotations(false);
         $entityCode = $entityGenerator->generateEntityClass($class);
     }
     $entityCode = str_replace(array("@var integer\n", "@var boolean\n", "@param integer\n", "@param boolean\n", "@return integer\n", "@return boolean\n"), array("@var int\n", "@var bool\n", "@param int\n", "@param bool\n", "@return int\n", "@return bool\n"), $entityCode);
     $this->filesystem->mkdir(dirname($entityPath));
     file_put_contents($entityPath, $entityCode);
     if ($mappingPath) {
         $this->filesystem->mkdir(dirname($mappingPath));
         file_put_contents($mappingPath, $mappingCode);
     }
     $path = $bundle->getPath() . str_repeat('/..', substr_count(get_class($bundle), '\\'));
     $this->getRepositoryGenerator()->writeEntityRepositoryClass($class->customRepositoryClassName, $path);
     $repositoryPath = $path . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class->customRepositoryClassName) . '.php';
     return new EntityGeneratorResult($entityPath, $repositoryPath, $mappingPath);
 }
开发者ID:coreight,项目名称:SensioGeneratorBundle,代码行数:56,代码来源:DoctrineEntityGenerator.php

示例3: generate

 /**
  * {@inheritdoc}
  */
 public function generate($resourceName, OutputInterface $output = null)
 {
     if (!$this->_initialized) {
         $this->buildDefaultConfiguration($resourceName, $output);
     }
     $entityClass = $this->configuration['namespace'] . '\\' . $this->model;
     $modelPath = $this->configuration['directory'] . '/' . $this->model . '.php';
     if (file_exists($modelPath)) {
         $this->addError(sprintf('Model "%s" already exist.', $modelPath));
         return false;
     }
     $class = new ClassMetadataInfo($entityClass);
     $class->isMappedSuperclass = true;
     $class->setPrimaryTable(array('name' => strtolower($this->model)));
     $class->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
     $class->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
     foreach ($this->configuration['fields'] as $field) {
         $class->mapField($field);
     }
     $entityGenerator = $this->getEntityGenerator();
     if ($this->configuration['with_interface']) {
         $fields = $this->getFieldsFromMetadata($class);
         $this->renderFile('model/ModelInterface.php.twig', $this->configuration['directory'] . '/' . $this->model . 'Interface.php', array('fields' => $fields, 'namespace' => $this->configuration['namespace'], 'class_name' => $this->model . 'Interface'));
     }
     $cme = new ClassMetadataExporter();
     $exporter = $cme->getExporter('yml' == $this->configuration['format'] ? 'yaml' : $this->configuration['format']);
     $mappingPath = $this->bundle->getPath() . '/Resources/config/doctrine/model/' . $this->model . '.orm.' . $this->configuration['format'];
     if (file_exists($mappingPath)) {
         $this->addError(sprintf('Cannot generate model when mapping "%s" already exists.', $mappingPath));
         return false;
     }
     $mappingCode = $exporter->exportClassMetadata($class);
     $entityGenerator->setGenerateAnnotations(false);
     $entityCode = $entityGenerator->generateEntityClass($class);
     file_put_contents($modelPath, $entityCode);
     if ($mappingPath) {
         $this->fileSystem->mkdir(dirname($mappingPath));
         file_put_contents($mappingPath, $mappingCode);
     }
     $this->renderFile('model/Repository.php.twig', $this->bundle->getPath() . '/Doctrine/ORM/' . $this->model . 'Repository.php', array('namespace' => $this->bundle->getNamespace() . '\\Doctrine\\ORM', 'class_name' => $this->model . 'Repository'));
     $this->patchDependencyInjection();
 }
开发者ID:avoo,项目名称:FrameworkGeneratorBundle,代码行数:45,代码来源:Model.php

示例4: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
 {
     $xmlRoot = $this->getElement($className);
     if ($xmlRoot->getName() == 'entity') {
         if (isset($xmlRoot['repository-class'])) {
             $metadata->setCustomRepositoryClass((string) $xmlRoot['repository-class']);
         }
         if (isset($xmlRoot['read-only']) && $xmlRoot['read-only'] == "true") {
             $metadata->markReadOnly();
         }
     } else {
         if ($xmlRoot->getName() == 'mapped-superclass') {
             $metadata->setCustomRepositoryClass(isset($xmlRoot['repository-class']) ? (string) $xmlRoot['repository-class'] : null);
             $metadata->isMappedSuperclass = true;
         } else {
             throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
         }
     }
     // Evaluate <entity...> attributes
     $table = array();
     if (isset($xmlRoot['table'])) {
         $table['name'] = (string) $xmlRoot['table'];
     }
     $metadata->setPrimaryTable($table);
     // Evaluate named queries
     if (isset($xmlRoot['named-queries'])) {
         foreach ($xmlRoot->{'named-queries'}->{'named-query'} as $namedQueryElement) {
             $metadata->addNamedQuery(array('name' => (string) $namedQueryElement['name'], 'query' => (string) $namedQueryElement['query']));
         }
     }
     /* not implemented specially anyway. use table = schema.table
        if (isset($xmlRoot['schema'])) {
            $metadata->table['schema'] = (string)$xmlRoot['schema'];
        }*/
     if (isset($xmlRoot['inheritance-type'])) {
         $inheritanceType = (string) $xmlRoot['inheritance-type'];
         $metadata->setInheritanceType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceType));
         if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) {
             // Evaluate <discriminator-column...>
             if (isset($xmlRoot->{'discriminator-column'})) {
                 $discrColumn = $xmlRoot->{'discriminator-column'};
                 $metadata->setDiscriminatorColumn(array('name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null, 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : null, 'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : null, 'columnDefinition' => isset($discrColumn['column-definition']) ? (string) $discrColumn['column-definition'] : null));
             } else {
                 $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255));
             }
             // Evaluate <discriminator-map...>
             if (isset($xmlRoot->{'discriminator-map'})) {
                 $map = array();
                 foreach ($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} as $discrMapElement) {
                     $map[(string) $discrMapElement['value']] = (string) $discrMapElement['class'];
                 }
                 $metadata->setDiscriminatorMap($map);
             }
         }
     }
     // Evaluate <change-tracking-policy...>
     if (isset($xmlRoot['change-tracking-policy'])) {
         $metadata->setChangeTrackingPolicy(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::CHANGETRACKING_' . strtoupper((string) $xmlRoot['change-tracking-policy'])));
     }
     // Evaluate <indexes...>
     if (isset($xmlRoot->indexes)) {
         $metadata->table['indexes'] = array();
         foreach ($xmlRoot->indexes->index as $index) {
             $columns = explode(',', (string) $index['columns']);
             if (isset($index['name'])) {
                 $metadata->table['indexes'][(string) $index['name']] = array('columns' => $columns);
             } else {
                 $metadata->table['indexes'][] = array('columns' => $columns);
             }
         }
     }
     // Evaluate <unique-constraints..>
     if (isset($xmlRoot->{'unique-constraints'})) {
         $metadata->table['uniqueConstraints'] = array();
         foreach ($xmlRoot->{'unique-constraints'}->{'unique-constraint'} as $unique) {
             $columns = explode(',', (string) $unique['columns']);
             if (isset($unique['name'])) {
                 $metadata->table['uniqueConstraints'][(string) $unique['name']] = array('columns' => $columns);
             } else {
                 $metadata->table['uniqueConstraints'][] = array('columns' => $columns);
             }
         }
     }
     if (isset($xmlRoot->options)) {
         $metadata->table['options'] = $this->_parseOptions($xmlRoot->options->children());
     }
     // Evaluate <field ...> mappings
     if (isset($xmlRoot->field)) {
         foreach ($xmlRoot->field as $fieldMapping) {
             $mapping = array('fieldName' => (string) $fieldMapping['name']);
             if (isset($fieldMapping['type'])) {
                 $mapping['type'] = (string) $fieldMapping['type'];
             }
             if (isset($fieldMapping['column'])) {
                 $mapping['columnName'] = (string) $fieldMapping['column'];
             }
             if (isset($fieldMapping['length'])) {
//.........这里部分代码省略.........
开发者ID:SerdarSanri,项目名称:doctrine-bundle,代码行数:101,代码来源:XmlDriver.php

示例5: loadMetadata

 public static function loadMetadata(ClassMetadataInfo $metadata)
 {
     $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');
     $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, 'inversedBy' => 'user', 'joinColumns' => array(0 => array('name' => 'address_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE')), 'orphanRemoval' => false));
     $metadata->mapOneToMany(array('fieldName' => 'phonenumbers', 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Phonenumber', 'cascade' => array(1 => 'persist'), 'mappedBy' => 'user', 'orphanRemoval' => true, '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));
     $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));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:19,代码来源:AbstractMappingDriverTest.php

示例6: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
 {
     $class = $metadata->getReflectionClass();
     if (!$class) {
         // this happens when running annotation driver in combination with
         // static reflection services. This is not the nicest fix
         $class = new \ReflectionClass($metadata->name);
     }
     $classAnnotations = $this->_reader->getClassAnnotations($class);
     // Compatibility with Doctrine Common 3.x
     if ($classAnnotations && is_int(key($classAnnotations))) {
         foreach ($classAnnotations as $annot) {
             $classAnnotations[get_class($annot)] = $annot;
         }
     }
     // Evaluate Entity annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\Entity'])) {
         $entityAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\Entity'];
         if ($entityAnnot->repositoryClass !== null) {
             $metadata->setCustomRepositoryClass($entityAnnot->repositoryClass);
         }
         if ($entityAnnot->readOnly) {
             $metadata->markReadOnly();
         }
     } else {
         if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\MappedSuperclass'])) {
             $mappedSuperclassAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\MappedSuperclass'];
             $metadata->setCustomRepositoryClass($mappedSuperclassAnnot->repositoryClass);
             $metadata->isMappedSuperclass = true;
         } else {
             throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
         }
     }
     // Evaluate Table annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\Table'])) {
         $tableAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\Table'];
         $primaryTable = array('name' => $tableAnnot->name, 'schema' => $tableAnnot->schema);
         if ($tableAnnot->indexes !== null) {
             foreach ($tableAnnot->indexes as $indexAnnot) {
                 $primaryTable['indexes'][$indexAnnot->name] = array('columns' => $indexAnnot->columns);
             }
         }
         if ($tableAnnot->uniqueConstraints !== null) {
             foreach ($tableAnnot->uniqueConstraints as $uniqueConstraint) {
                 $primaryTable['uniqueConstraints'][$uniqueConstraint->name] = array('columns' => $uniqueConstraint->columns);
             }
         }
         if ($tableAnnot->options !== null) {
             $primaryTable['options'] = $tableAnnot->options;
         }
         $metadata->setPrimaryTable($primaryTable);
     }
     // Evaluate NamedQueries annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\NamedQueries'])) {
         $namedQueriesAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\NamedQueries'];
         if (!is_array($namedQueriesAnnot->value)) {
             throw new \UnexpectedValueException("@NamedQueries should contain an array of @NamedQuery annotations.");
         }
         foreach ($namedQueriesAnnot->value as $namedQuery) {
             if (!$namedQuery instanceof \Doctrine\ORM\Mapping\NamedQuery) {
                 throw new \UnexpectedValueException("@NamedQueries should contain an array of @NamedQuery annotations.");
             }
             $metadata->addNamedQuery(array('name' => $namedQuery->name, 'query' => $namedQuery->query));
         }
     }
     // Evaluate InheritanceType annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\InheritanceType'])) {
         $inheritanceTypeAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\InheritanceType'];
         $metadata->setInheritanceType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
         if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) {
             // Evaluate DiscriminatorColumn annotation
             if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorColumn'])) {
                 $discrColumnAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorColumn'];
                 $metadata->setDiscriminatorColumn(array('name' => $discrColumnAnnot->name, 'type' => $discrColumnAnnot->type, 'length' => $discrColumnAnnot->length, 'columnDefinition' => $discrColumnAnnot->columnDefinition));
             } else {
                 $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255));
             }
             // Evaluate DiscriminatorMap annotation
             if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorMap'])) {
                 $discrMapAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorMap'];
                 $metadata->setDiscriminatorMap($discrMapAnnot->value);
             }
         }
     }
     // Evaluate DoctrineChangeTrackingPolicy annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\ChangeTrackingPolicy'])) {
         $changeTrackingAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\ChangeTrackingPolicy'];
         $metadata->setChangeTrackingPolicy(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::CHANGETRACKING_' . $changeTrackingAnnot->value));
     }
     // Evaluate annotations on properties/fields
     foreach ($class->getProperties() as $property) {
         if ($metadata->isMappedSuperclass && !$property->isPrivate() || $metadata->isInheritedField($property->name) || $metadata->isInheritedAssociation($property->name)) {
             continue;
         }
         $mapping = array();
         $mapping['fieldName'] = $property->getName();
         // Check for JoinColummn/JoinColumns annotations
//.........这里部分代码省略.........
开发者ID:SerdarSanri,项目名称:doctrine-bundle,代码行数:101,代码来源:AnnotationDriver.php

示例7: setTable

 /**
  * Sets the table name.
  *
  * @param string $name
  *
  * @return ClassMetadataBuilder
  */
 public function setTable($name)
 {
     $this->cm->setPrimaryTable(array('name' => $name));
     return $this;
 }
开发者ID:nemekzg,项目名称:doctrine2,代码行数:12,代码来源:ClassMetadataBuilder.php

示例8: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
 {
     $element = $this->getElement($className);
     if ($element['type'] == 'entity') {
         if (isset($element['repositoryClass'])) {
             $metadata->setCustomRepositoryClass($element['repositoryClass']);
         }
         if (isset($element['readOnly']) && $element['readOnly'] == true) {
             $metadata->markReadOnly();
         }
     } else {
         if ($element['type'] == 'mappedSuperclass') {
             $metadata->setCustomRepositoryClass(isset($element['repositoryClass']) ? $element['repositoryClass'] : null);
             $metadata->isMappedSuperclass = true;
         } else {
             throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
         }
     }
     // Evaluate root level properties
     $table = array();
     if (isset($element['table'])) {
         $table['name'] = $element['table'];
     }
     $metadata->setPrimaryTable($table);
     // Evaluate named queries
     if (isset($element['namedQueries'])) {
         foreach ($element['namedQueries'] as $name => $queryMapping) {
             if (is_string($queryMapping)) {
                 $queryMapping = array('query' => $queryMapping);
             }
             if (!isset($queryMapping['name'])) {
                 $queryMapping['name'] = $name;
             }
             $metadata->addNamedQuery($queryMapping);
         }
     }
     /* not implemented specially anyway. use table = schema.table
        if (isset($element['schema'])) {
            $metadata->table['schema'] = $element['schema'];
        }*/
     if (isset($element['inheritanceType'])) {
         $metadata->setInheritanceType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($element['inheritanceType'])));
         if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) {
             // Evaluate discriminatorColumn
             if (isset($element['discriminatorColumn'])) {
                 $discrColumn = $element['discriminatorColumn'];
                 $metadata->setDiscriminatorColumn(array('name' => $discrColumn['name'], 'type' => $discrColumn['type'], 'length' => $discrColumn['length']));
             } else {
                 $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255));
             }
             // Evaluate discriminatorMap
             if (isset($element['discriminatorMap'])) {
                 $metadata->setDiscriminatorMap($element['discriminatorMap']);
             }
         }
     }
     // Evaluate changeTrackingPolicy
     if (isset($element['changeTrackingPolicy'])) {
         $metadata->setChangeTrackingPolicy(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::CHANGETRACKING_' . strtoupper($element['changeTrackingPolicy'])));
     }
     // Evaluate indexes
     if (isset($element['indexes'])) {
         foreach ($element['indexes'] as $name => $index) {
             if (!isset($index['name'])) {
                 $index['name'] = $name;
             }
             if (is_string($index['columns'])) {
                 $columns = explode(',', $index['columns']);
             } else {
                 $columns = $index['columns'];
             }
             $metadata->table['indexes'][$index['name']] = array('columns' => $columns);
         }
     }
     // Evaluate uniqueConstraints
     if (isset($element['uniqueConstraints'])) {
         foreach ($element['uniqueConstraints'] as $name => $unique) {
             if (!isset($unique['name'])) {
                 $unique['name'] = $name;
             }
             if (is_string($unique['columns'])) {
                 $columns = explode(',', $unique['columns']);
             } else {
                 $columns = $unique['columns'];
             }
             $metadata->table['uniqueConstraints'][$unique['name']] = array('columns' => $columns);
         }
     }
     $associationIds = array();
     if (isset($element['id'])) {
         // Evaluate identifier settings
         foreach ($element['id'] as $name => $idElement) {
             if (isset($idElement['associationKey']) && $idElement['associationKey'] == true) {
                 $associationIds[$name] = true;
                 continue;
             }
             $mapping = array('id' => true, 'fieldName' => $name);
//.........这里部分代码省略.........
开发者ID:williamamed,项目名称:Raptor2,代码行数:101,代码来源:YamlDriver.php

示例9: loadMetadata

 public static function loadMetadata(ClassMetadataInfo $metadata)
 {
     $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE);
     $metadata->setPrimaryTable(array('indexes' => array(array('columns' => array('content'), 'flags' => array('fulltext'), 'options' => array('where' => 'content IS NOT NULL')))));
     $metadata->mapField(array('fieldName' => 'content', 'type' => 'text', 'scale' => 0, 'length' => NULL, 'unique' => false, 'nullable' => false, 'precision' => 0, 'columnName' => 'content'));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:6,代码来源:AbstractMappingDriverTest.php

示例10: generateEntity

 /**
  * Generate the entity PHP code.
  *
  * @param BundleInterface $bundle
  * @param string          $name
  * @param array           $fields
  * @param string          $namePrefix
  * @param string          $dbPrefix
  * @param string|null     $extendClass
  *
  * @return array
  * @throws \RuntimeException
  */
 protected function generateEntity(BundleInterface $bundle, $name, $fields, $namePrefix, $dbPrefix, $extendClass = null)
 {
     // configure the bundle (needed if the bundle does not contain any Entities yet)
     $config = $this->registry->getManager(null)->getConfiguration();
     $config->setEntityNamespaces(array_merge(array($bundle->getName() => $bundle->getNamespace() . '\\Entity\\' . $namePrefix), $config->getEntityNamespaces()));
     $entityClass = $this->registry->getAliasNamespace($bundle->getName()) . '\\' . $namePrefix . '\\' . $name;
     $entityPath = $bundle->getPath() . '/Entity/' . $namePrefix . '/' . str_replace('\\', '/', $name) . '.php';
     if (file_exists($entityPath)) {
         throw new \RuntimeException(sprintf('Entity "%s" already exists.', $entityClass));
     }
     $class = new ClassMetadataInfo($entityClass, new UnderscoreNamingStrategy());
     foreach ($fields as $fieldSet) {
         foreach ($fieldSet as $fieldArray) {
             foreach ($fieldArray as $field) {
                 if (array_key_exists('joinColumn', $field)) {
                     $class->mapManyToOne($field);
                 } elseif (array_key_exists('joinTable', $field)) {
                     $class->mapManyToMany($field);
                 } else {
                     $class->mapField($field);
                 }
             }
         }
     }
     $class->setPrimaryTable(array('name' => strtolower($dbPrefix . strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name))) . 's'));
     $entityCode = $this->getEntityGenerator($extendClass)->generateEntityClass($class);
     return array($entityCode, $entityPath);
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:41,代码来源:KunstmaanGenerator.php

示例11: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
 {
     $class = $metadata->getReflectionClass();
     $classAnnotations = $this->_reader->getClassAnnotations($class);
     // Evaluate Entity annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\Entity'])) {
         $entityAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\Entity'];
         $metadata->setCustomRepositoryClass($entityAnnot->repositoryClass);
     } else {
         if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\MappedSuperclass'])) {
             $metadata->isMappedSuperclass = true;
         } else {
             throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
         }
     }
     // Evaluate DoctrineTable annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\Table'])) {
         $tableAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\Table'];
         $primaryTable = array('name' => $tableAnnot->name, 'schema' => $tableAnnot->schema);
         if ($tableAnnot->indexes !== null) {
             foreach ($tableAnnot->indexes as $indexAnnot) {
                 $primaryTable['indexes'][$indexAnnot->name] = array('columns' => $indexAnnot->columns);
             }
         }
         if ($tableAnnot->uniqueConstraints !== null) {
             foreach ($tableAnnot->uniqueConstraints as $uniqueConstraint) {
                 $primaryTable['uniqueConstraints'][$uniqueConstraint->name] = array('columns' => $uniqueConstraint->columns);
             }
         }
         $metadata->setPrimaryTable($primaryTable);
     }
     // Evaluate InheritanceType annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\InheritanceType'])) {
         $inheritanceTypeAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\InheritanceType'];
         $metadata->setInheritanceType(constant('\\Doctrine\\ORM\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
     }
     // Evaluate DiscriminatorColumn annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorColumn'])) {
         $discrColumnAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorColumn'];
         $metadata->setDiscriminatorColumn(array('name' => $discrColumnAnnot->name, 'type' => $discrColumnAnnot->type, 'length' => $discrColumnAnnot->length));
     }
     // Evaluate DiscriminatorMap annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorMap'])) {
         $discrMapAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\DiscriminatorMap'];
         $metadata->setDiscriminatorMap($discrMapAnnot->value);
     }
     // Evaluate DoctrineChangeTrackingPolicy annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\ChangeTrackingPolicy'])) {
         $changeTrackingAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\ChangeTrackingPolicy'];
         $metadata->setChangeTrackingPolicy($changeTrackingAnnot->value);
     }
     // Evaluate annotations on properties/fields
     foreach ($class->getProperties() as $property) {
         if ($metadata->isMappedSuperclass && !$property->isPrivate() || $metadata->isInheritedField($property->name) || $metadata->isInheritedAssociation($property->name)) {
             continue;
         }
         $mapping = array();
         $mapping['fieldName'] = $property->getName();
         // Check for JoinColummn/JoinColumns annotations
         $joinColumns = array();
         if ($joinColumnAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\JoinColumn')) {
             $joinColumns[] = array('name' => $joinColumnAnnot->name, 'referencedColumnName' => $joinColumnAnnot->referencedColumnName, 'unique' => $joinColumnAnnot->unique, 'nullable' => $joinColumnAnnot->nullable, 'onDelete' => $joinColumnAnnot->onDelete, 'onUpdate' => $joinColumnAnnot->onUpdate, 'columnDefinition' => $joinColumnAnnot->columnDefinition);
         } else {
             if ($joinColumnsAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\JoinColumns')) {
                 foreach ($joinColumnsAnnot->value as $joinColumn) {
                     $joinColumns[] = array('name' => $joinColumn->name, 'referencedColumnName' => $joinColumn->referencedColumnName, 'unique' => $joinColumn->unique, 'nullable' => $joinColumn->nullable, 'onDelete' => $joinColumn->onDelete, 'onUpdate' => $joinColumn->onUpdate, 'columnDefinition' => $joinColumn->columnDefinition);
                 }
             }
         }
         // Field can only be annotated with one of:
         // @Column, @OneToOne, @OneToMany, @ManyToOne, @ManyToMany
         if ($columnAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Column')) {
             if ($columnAnnot->type == null) {
                 throw MappingException::propertyTypeIsRequired($className, $property->getName());
             }
             $mapping['type'] = $columnAnnot->type;
             $mapping['length'] = $columnAnnot->length;
             $mapping['precision'] = $columnAnnot->precision;
             $mapping['scale'] = $columnAnnot->scale;
             $mapping['nullable'] = $columnAnnot->nullable;
             $mapping['unique'] = $columnAnnot->unique;
             if ($columnAnnot->options) {
                 $mapping['options'] = $columnAnnot->options;
             }
             if (isset($columnAnnot->name)) {
                 $mapping['columnName'] = $columnAnnot->name;
             }
             if (isset($columnAnnot->columnDefinition)) {
                 $mapping['columnDefinition'] = $columnAnnot->columnDefinition;
             }
             if ($idAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Id')) {
                 $mapping['id'] = true;
             }
             if ($generatedValueAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\GeneratedValue')) {
                 $metadata->setIdGeneratorType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::GENERATOR_TYPE_' . $generatedValueAnnot->strategy));
             }
             if ($versionAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Version')) {
//.........这里部分代码省略.........
开发者ID:nvdnkpr,项目名称:symfony-demo,代码行数:101,代码来源:AnnotationDriver.php

示例12: loadMetadata

 public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
 {
     $metadata->setPrimaryTable(array('name' => 'company_person'));
     $metadata->addNamedNativeQuery(array('name' => 'find-all', 'query' => 'SELECT id, country, city FROM cms_addresses', 'resultSetMapping' => 'mapping-find-all'));
     $metadata->addNamedNativeQuery(array('name' => 'find-by-id', 'query' => 'SELECT * FROM cms_addresses WHERE id = ?', 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress'));
     $metadata->addNamedNativeQuery(array('name' => 'count', 'query' => 'SELECT COUNT(*) AS count FROM cms_addresses', 'resultSetMapping' => 'mapping-count'));
     $metadata->addSqlResultSetMapping(array('name' => 'mapping-find-all', 'columns' => array(), 'entities' => array(array('fields' => array(array('name' => 'id', 'column' => 'id'), array('name' => 'city', 'column' => 'city'), array('name' => 'country', 'column' => 'country')), 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress'))));
     $metadata->addSqlResultSetMapping(array('name' => 'mapping-without-fields', 'columns' => array(), 'entities' => array(array('entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress', 'fields' => array()))));
     $metadata->addSqlResultSetMapping(array('name' => 'mapping-count', 'columns' => array(array('name' => 'count'))));
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:10,代码来源:CmsAddress.php

示例13: loadMetadata

 public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
 {
     $metadata->setPrimaryTable(array('name' => 'company_person'));
     $metadata->addNamedNativeQuery(array('name' => 'fetchAllWithResultClass', 'query' => 'SELECT id, name, discr FROM company_persons ORDER BY name', 'resultClass' => 'Doctrine\\Tests\\Models\\Company\\CompanyPerson'));
     $metadata->addNamedNativeQuery(array('name' => 'fetchAllWithSqlResultSetMapping', 'query' => 'SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name', 'resultSetMapping' => 'mappingFetchAll'));
     $metadata->addSqlResultSetMapping(array('name' => 'mappingFetchAll', 'columns' => array(), 'entities' => array(array('fields' => array(array('name' => 'id', 'column' => 'id'), array('name' => 'name', 'column' => 'name')), 'entityClass' => 'Doctrine\\Tests\\Models\\Company\\CompanyPerson', 'discriminatorColumn' => 'discriminator'))));
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:7,代码来源:CompanyPerson.php

示例14: getTestMetadataProcessingData

 /**
  * Data provider for testMetadataProcessing().
  *
  * @return array
  * @throws \Doctrine\ORM\Mapping\MappingException
  */
 public function getTestMetadataProcessingData()
 {
     $out = [];
     /** @var ObjectManager $entityManager Common data for most test cases. */
     $entityManager = $this->getMock('Doctrine\\ORM\\EntityManagerInterface');
     $baseMapping = ['fieldName' => 'fieldNameValue'];
     $replacements = ['@placeholder' => '_1'];
     // Case 0: no replacements, no mapping.
     $classMetadataInfo = new ClassMetadataInfo('someEntity');
     $input = new LoadClassMetadataEventArgs($classMetadataInfo, $entityManager);
     $output = new LoadClassMetadataEventArgs($classMetadataInfo, $entityManager);
     $out[] = [[], $input, $output];
     // Case 1: no replacements, default mappings.
     $inputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $inputClassMetadataInfo->mapField($baseMapping);
     $input = new LoadClassMetadataEventArgs($inputClassMetadataInfo, $entityManager);
     $outputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $outputClassMetadataInfo->mapField($baseMapping);
     $output = new LoadClassMetadataEventArgs($outputClassMetadataInfo, $entityManager);
     $out[] = [[], $input, $output];
     // Case 2: no replacements.
     $inputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $inputClassMetadataInfo->mapField(array_merge($baseMapping, ['key' => 'value']));
     $input = new LoadClassMetadataEventArgs($inputClassMetadataInfo, $entityManager);
     $outputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $outputClassMetadataInfo->mapField(array_merge($baseMapping, ['key' => 'value']));
     $output = new LoadClassMetadataEventArgs($outputClassMetadataInfo, $entityManager);
     $out[] = [[], $input, $output];
     // Case 3: irrelevant replacements.
     $inputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $inputClassMetadataInfo->mapField(array_merge($baseMapping, ['key' => 'value']));
     $input = new LoadClassMetadataEventArgs($inputClassMetadataInfo, $entityManager);
     $outputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $outputClassMetadataInfo->mapField(array_merge($baseMapping, ['key' => 'value']));
     $output = new LoadClassMetadataEventArgs($outputClassMetadataInfo, $entityManager);
     $out[] = [$replacements, $input, $output];
     // Case 4: replacements provided.
     $inputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $inputClassMetadataInfo->mapField(array_merge($baseMapping, ['key' => 'value@placeholder']));
     $input = new LoadClassMetadataEventArgs($inputClassMetadataInfo, $entityManager);
     $outputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $outputClassMetadataInfo->mapField(array_merge($baseMapping, ['key' => 'value_1']));
     $output = new LoadClassMetadataEventArgs($outputClassMetadataInfo, $entityManager);
     $out[] = [$replacements, $input, $output];
     // Case 5: nested annotations.
     $inputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $inputClassMetadataInfo->mapField(array_merge($baseMapping, ['key' => ['internalKey' => ['value@placeholder']]]));
     $input = new LoadClassMetadataEventArgs($inputClassMetadataInfo, $entityManager);
     $outputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $outputClassMetadataInfo->mapField(array_merge($baseMapping, ['key' => ['internalKey' => ['value@placeholder']]]));
     $output = new LoadClassMetadataEventArgs($outputClassMetadataInfo, $entityManager);
     $out[] = [$replacements, $input, $output];
     // Case 6: replacing table name.
     $inputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $inputClassMetadataInfo->mapField($baseMapping);
     $inputClassMetadataInfo->setPrimaryTable(['name' => 'my_table@placeholder']);
     $input = new LoadClassMetadataEventArgs($inputClassMetadataInfo, $entityManager);
     $outputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $outputClassMetadataInfo->mapField($baseMapping);
     $outputClassMetadataInfo->setPrimaryTable(['name' => 'my_table_1']);
     $output = new LoadClassMetadataEventArgs($outputClassMetadataInfo, $entityManager);
     $out[] = [$replacements, $input, $output];
     // Case 7: one-to-one mapping.
     $replacements = ['@placeholder' => '_1'];
     $inputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $inputClassMetadataInfo->setPrimaryTable(['name' => 'my_table']);
     $inputClassMetadataInfo->mapOneToOne(array_merge($baseMapping, ['targetEntity' => 'whatever', 'joinColumns' => [['name' => 'someName', 'referencedColumnName' => 'FK@placeholder']]]));
     $input = new LoadClassMetadataEventArgs($inputClassMetadataInfo, $entityManager);
     $outputClassMetadataInfo = new ClassMetadataInfo('someEntity');
     $outputClassMetadataInfo->setPrimaryTable(['name' => 'my_table']);
     $outputClassMetadataInfo->mapOneToOne(array_merge($baseMapping, ['targetEntity' => 'whatever', 'joinColumns' => [['name' => 'someName', 'referencedColumnName' => 'FK_1']], 'joinTableColumns' => null, 'relationToSourceKeyColumns' => null, 'relationToTargetKeyColumns' => null]));
     $output = new LoadClassMetadataEventArgs($outputClassMetadataInfo, $entityManager);
     $out[] = [$replacements, $input, $output];
     return $out;
 }
开发者ID:asev,项目名称:ConnectionsBundle,代码行数:81,代码来源:LoadClassMetadataListenerTest.php

示例15: loadMetadata

 public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
 {
     $metadata->setPrimaryTable(array('name' => 'cms_users'));
     $metadata->addNamedNativeQuery(array('name' => 'fetchIdAndUsernameWithResultClass', 'query' => 'SELECT id, username FROM cms_users WHERE username = ?', 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser'));
     $metadata->addNamedNativeQuery(array('name' => 'fetchAllColumns', 'query' => 'SELECT * FROM cms_users WHERE username = ?', 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser'));
     $metadata->addNamedNativeQuery(array('name' => 'fetchJoinedAddress', 'query' => 'SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', 'resultSetMapping' => 'mappingJoinedAddress'));
     $metadata->addNamedNativeQuery(array('name' => 'fetchJoinedPhonenumber', 'query' => 'SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', 'resultSetMapping' => 'mappingJoinedPhonenumber'));
     $metadata->addNamedNativeQuery(array('name' => 'fetchUserPhonenumberCount', 'query' => 'SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username', 'resultSetMapping' => 'mappingUserPhonenumberCount'));
     $metadata->addNamedNativeQuery(array("name" => "fetchMultipleJoinsEntityResults", "resultSetMapping" => "mappingMultipleJoinsEntityResults", "query" => "SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username"));
     $metadata->addSqlResultSetMapping(array('name' => 'mappingJoinedAddress', 'columns' => array(), 'entities' => array(array('fields' => array(array('name' => 'id', 'column' => 'id'), array('name' => 'name', 'column' => 'name'), array('name' => 'status', 'column' => 'status'), array('name' => 'address.zip', 'column' => 'zip'), array('name' => 'address.city', 'column' => 'city'), array('name' => 'address.country', 'column' => 'country'), array('name' => 'address.id', 'column' => 'a_id')), 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', 'discriminatorColumn' => null))));
     $metadata->addSqlResultSetMapping(array('name' => 'mappingJoinedPhonenumber', 'columns' => array(), 'entities' => array(array('fields' => array(array('name' => 'id', 'column' => 'id'), array('name' => 'name', 'column' => 'name'), array('name' => 'status', 'column' => 'status'), array('name' => 'phonenumbers.phonenumber', 'column' => 'number')), 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', 'discriminatorColumn' => null))));
     $metadata->addSqlResultSetMapping(array('name' => 'mappingUserPhonenumberCount', 'columns' => array(), 'entities' => array(array('fields' => array(array('name' => 'id', 'column' => 'id'), array('name' => 'name', 'column' => 'name'), array('name' => 'status', 'column' => 'status')), 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', 'discriminatorColumn' => null)), 'columns' => array(array('name' => 'numphones'))));
     $metadata->addSqlResultSetMapping(array('name' => 'mappingMultipleJoinsEntityResults', 'entities' => array(array('fields' => array(array('name' => 'id', 'column' => 'u_id'), array('name' => 'name', 'column' => 'u_name'), array('name' => 'status', 'column' => 'u_status')), 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', 'discriminatorColumn' => null), array('fields' => array(array('name' => 'id', 'column' => 'a_id'), array('name' => 'zip', 'column' => 'a_zip'), array('name' => 'country', 'column' => 'a_country')), 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress', 'discriminatorColumn' => null)), 'columns' => array(array('name' => 'numphones'))));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:14,代码来源:CmsUser.php


注:本文中的Doctrine\ORM\Mapping\ClassMetadataInfo::setPrimaryTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。