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


PHP ClassMetadataInfo::addSqlResultSetMapping方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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']));
         }
     }
     // Evaluate native named queries
     if (isset($xmlRoot->{'named-native-queries'})) {
         foreach ($xmlRoot->{'named-native-queries'}->{'named-native-query'} as $nativeQueryElement) {
             $metadata->addNamedNativeQuery(array('name' => isset($nativeQueryElement['name']) ? (string) $nativeQueryElement['name'] : null, 'query' => isset($nativeQueryElement->query) ? (string) $nativeQueryElement->query : null, 'resultClass' => isset($nativeQueryElement['result-class']) ? (string) $nativeQueryElement['result-class'] : null, 'resultSetMapping' => isset($nativeQueryElement['result-set-mapping']) ? (string) $nativeQueryElement['result-set-mapping'] : null));
         }
     }
     // Evaluate sql result set mapping
     if (isset($xmlRoot->{'sql-result-set-mappings'})) {
         foreach ($xmlRoot->{'sql-result-set-mappings'}->{'sql-result-set-mapping'} as $rsmElement) {
             $entities = array();
             $columns = array();
             foreach ($rsmElement as $entityElement) {
                 //<entity-result/>
                 if (isset($entityElement['entity-class'])) {
                     $entityResult = array('fields' => array(), 'entityClass' => (string) $entityElement['entity-class'], 'discriminatorColumn' => isset($entityElement['discriminator-column']) ? (string) $entityElement['discriminator-column'] : null);
                     foreach ($entityElement as $fieldElement) {
                         $entityResult['fields'][] = array('name' => isset($fieldElement['name']) ? (string) $fieldElement['name'] : null, 'column' => isset($fieldElement['column']) ? (string) $fieldElement['column'] : null);
                     }
                     $entities[] = $entityResult;
                 }
                 //<column-result/>
                 if (isset($entityElement['name'])) {
                     $columns[] = array('name' => (string) $entityElement['name']);
                 }
             }
             $metadata->addSqlResultSetMapping(array('name' => (string) $rsmElement['name'], 'entities' => $entities, 'columns' => $columns));
         }
     }
     /* 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);
             }
//.........这里部分代码省略.........
开发者ID:naumangcu,项目名称:doctrine2,代码行数:101,代码来源:XmlDriver.php

示例4: 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);
     if ($classAnnotations && is_numeric(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) {
                 $index = array('columns' => $indexAnnot->columns);
                 if (!empty($indexAnnot->name)) {
                     $primaryTable['indexes'][$indexAnnot->name] = $index;
                 } else {
                     $primaryTable['indexes'][] = $index;
                 }
             }
         }
         if ($tableAnnot->uniqueConstraints !== null) {
             foreach ($tableAnnot->uniqueConstraints as $uniqueConstraintAnnot) {
                 $uniqueConstraint = array('columns' => $uniqueConstraintAnnot->columns);
                 if (!empty($uniqueConstraintAnnot->name)) {
                     $primaryTable['uniqueConstraints'][$uniqueConstraintAnnot->name] = $uniqueConstraint;
                 } else {
                     $primaryTable['uniqueConstraints'][] = $uniqueConstraint;
                 }
             }
         }
         if ($tableAnnot->options !== null) {
             $primaryTable['options'] = $tableAnnot->options;
         }
         $metadata->setPrimaryTable($primaryTable);
     }
     // Evaluate NamedNativeQueries annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\NamedNativeQueries'])) {
         $namedNativeQueriesAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\NamedNativeQueries'];
         foreach ($namedNativeQueriesAnnot->value as $namedNativeQuery) {
             $metadata->addNamedNativeQuery(array('name' => $namedNativeQuery->name, 'query' => $namedNativeQuery->query, 'resultClass' => $namedNativeQuery->resultClass, 'resultSetMapping' => $namedNativeQuery->resultSetMapping));
         }
     }
     // Evaluate SqlResultSetMappings annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\SqlResultSetMappings'])) {
         $sqlResultSetMappingsAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\SqlResultSetMappings'];
         foreach ($sqlResultSetMappingsAnnot->value as $resultSetMapping) {
             $entities = array();
             $columns = array();
             foreach ($resultSetMapping->entities as $entityResultAnnot) {
                 $entityResult = array('fields' => array(), 'entityClass' => $entityResultAnnot->entityClass, 'discriminatorColumn' => $entityResultAnnot->discriminatorColumn);
                 foreach ($entityResultAnnot->fields as $fieldResultAnnot) {
                     $entityResult['fields'][] = array('name' => $fieldResultAnnot->name, 'column' => $fieldResultAnnot->column);
                 }
                 $entities[] = $entityResult;
             }
             foreach ($resultSetMapping->columns as $columnResultAnnot) {
                 $columns[] = array('name' => $columnResultAnnot->name);
             }
             $metadata->addSqlResultSetMapping(array('name' => $resultSetMapping->name, 'entities' => $entities, 'columns' => $columns));
         }
     }
     // 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.");
             }
//.........这里部分代码省略.........
开发者ID:richardmiller,项目名称:doctrine2,代码行数:101,代码来源:AnnotationDriver.php

示例5: 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

示例6: 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);
         }
     }
     // Evaluate named native queries
     if (isset($element['namedNativeQueries'])) {
         foreach ($element['namedNativeQueries'] as $name => $mappingElement) {
             if (!isset($mappingElement['name'])) {
                 $mappingElement['name'] = $name;
             }
             $metadata->addNamedNativeQuery(array('name' => $mappingElement['name'], 'query' => isset($mappingElement['query']) ? $mappingElement['query'] : null, 'resultClass' => isset($mappingElement['resultClass']) ? $mappingElement['resultClass'] : null, 'resultSetMapping' => isset($mappingElement['resultSetMapping']) ? $mappingElement['resultSetMapping'] : null));
         }
     }
     // Evaluate sql result set mappings
     if (isset($element['sqlResultSetMappings'])) {
         foreach ($element['sqlResultSetMappings'] as $name => $resultSetMapping) {
             if (!isset($resultSetMapping['name'])) {
                 $resultSetMapping['name'] = $name;
             }
             $entities = array();
             $columns = array();
             if (isset($resultSetMapping['entityResult'])) {
                 foreach ($resultSetMapping['entityResult'] as $entityResultElement) {
                     $entityResult = array('fields' => array(), 'entityClass' => isset($entityResultElement['entityClass']) ? $entityResultElement['entityClass'] : null, 'discriminatorColumn' => isset($entityResultElement['discriminatorColumn']) ? $entityResultElement['discriminatorColumn'] : null);
                     if (isset($entityResultElement['fieldResult'])) {
                         foreach ($entityResultElement['fieldResult'] as $fieldResultElement) {
                             $entityResult['fields'][] = array('name' => isset($fieldResultElement['name']) ? $fieldResultElement['name'] : null, 'column' => isset($fieldResultElement['column']) ? $fieldResultElement['column'] : null);
                         }
                     }
                     $entities[] = $entityResult;
                 }
             }
             if (isset($resultSetMapping['columnResult'])) {
                 foreach ($resultSetMapping['columnResult'] as $columnResultAnnot) {
                     $columns[] = array('name' => isset($columnResultAnnot['name']) ? $columnResultAnnot['name'] : null);
                 }
             }
             $metadata->addSqlResultSetMapping(array('name' => $resultSetMapping['name'], 'entities' => $entities, 'columns' => $columns));
         }
     }
     /* 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' => 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['columnDefinition']) ? (string) $discrColumn['columnDefinition'] : null));
             } 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
//.........这里部分代码省略.........
开发者ID:naumangcu,项目名称:doctrine2,代码行数:101,代码来源:YamlDriver.php

示例7: loadMetadata

 public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
 {
     $metadata->setPrimaryTable(array('name' => 'company_person'));
     $metadata->mapField(array('id' => true, 'fieldName' => 'id', 'type' => 'integer'));
     $metadata->mapField(array('fieldName' => 'zip', 'length' => 50));
     $metadata->mapField(array('fieldName' => 'city', 'length' => 50));
     $metadata->mapOneToOne(array('fieldName' => 'user', 'targetEntity' => 'CmsUser', 'joinColumns' => array(array('referencedColumnName' => 'id'))));
     $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'))));
     $metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CmsAddressListener', 'postPersist');
     $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CmsAddressListener', 'prePersist');
     $metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'CmsAddressListener', 'postUpdate');
     $metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'CmsAddressListener', 'preUpdate');
     $metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'CmsAddressListener', 'postRemove');
     $metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'CmsAddressListener', 'preRemove');
     $metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'CmsAddressListener', 'preFlush');
     $metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'CmsAddressListener', 'postLoad');
 }
开发者ID:selimcr,项目名称:servigases,代码行数:22,代码来源:CmsAddress.php


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