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


PHP ClassMetadata::isInheritanceTypeJoined方法代码示例

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


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

示例1: saveRevisionEntityData

 /**
  * @param ClassMetadata $class
  * @param array $entityData
  * @param string $revType
  */
 private function saveRevisionEntityData($class, $entityData, $revType)
 {
     $params = array($this->getRevisionId(), $revType);
     $types = array(\PDO::PARAM_INT, \PDO::PARAM_STR);
     $fields = array();
     foreach ($class->associationMappings as $field => $assoc) {
         if ($class->isInheritanceTypeJoined() && $class->isInheritedAssociation($field)) {
             continue;
         }
         if (($assoc['type'] & ClassMetadata::TO_ONE) > 0 && $assoc['isOwningSide']) {
             $data = isset($entityData[$field]) ? $entityData[$field] : null;
             $relatedId = false;
             if ($data !== null && $this->uow->isInIdentityMap($data)) {
                 $relatedId = $this->uow->getEntityIdentifier($data);
             }
             $targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
             foreach ($assoc['sourceToTargetKeyColumns'] as $sourceColumn => $targetColumn) {
                 $fields[$sourceColumn] = true;
                 if ($data === null) {
                     $params[] = null;
                     $types[] = \PDO::PARAM_STR;
                 } else {
                     $params[] = $relatedId ? $relatedId[$targetClass->fieldNames[$targetColumn]] : null;
                     $types[] = $targetClass->getTypeOfColumn($targetColumn);
                 }
             }
         }
     }
     foreach ($class->fieldNames as $field) {
         if (array_key_exists($field, $fields)) {
             continue;
         }
         if ($class->isInheritanceTypeJoined() && $class->isInheritedField($field) && !$class->isIdentifier($field)) {
             continue;
         }
         $params[] = isset($entityData[$field]) ? $entityData[$field] : null;
         $types[] = $class->fieldMappings[$field]['type'];
     }
     if ($class->isInheritanceTypeSingleTable()) {
         $params[] = $class->discriminatorValue;
         $types[] = $class->discriminatorColumn['type'];
     } elseif ($class->isInheritanceTypeJoined() && $class->name == $class->rootEntityName) {
         $params[] = $entityData[$class->discriminatorColumn['name']];
         $types[] = $class->discriminatorColumn['type'];
     }
     if ($class->isInheritanceTypeJoined() && $class->name != $class->rootEntityName && count($class->parentClasses)) {
         if (!isset($entityData[$class->discriminatorColumn['name']])) {
             $entityData[$class->discriminatorColumn['name']] = $class->discriminatorValue;
         }
         $this->saveRevisionEntityData($this->em->getClassMetadata($class->parentClasses[0]), $entityData, $revType);
     }
     $this->conn->executeUpdate($this->getInsertRevisionSQL($class), $params, $types);
 }
开发者ID:hayloft,项目名称:EntityAudit,代码行数:58,代码来源:LogRevisionsListener.php

示例2: getInsertRevisionSQL

 /**
  * @param ClassMetadata $class
  * @return string
  * @throws \Doctrine\DBAL\DBALException
  */
 private function getInsertRevisionSQL($class)
 {
     if (!isset($this->insertRevisionSQL[$class->name])) {
         $placeholders = array('?', '?');
         $tableName = $this->config->getTablePrefix() . $class->table['name'] . $this->config->getTableSuffix();
         $sql = "INSERT INTO " . $tableName . " (" . $this->config->getRevisionFieldName() . ", " . $this->config->getRevisionTypeFieldName();
         $fields = array();
         foreach ($class->associationMappings as $field => $assoc) {
             if ($class->isInheritanceTypeJoined() && $class->isInheritedAssociation($field)) {
                 continue;
             }
             if (($assoc['type'] & ClassMetadata::TO_ONE) > 0 && $assoc['isOwningSide']) {
                 foreach ($assoc['targetToSourceKeyColumns'] as $sourceCol) {
                     $fields[$sourceCol] = true;
                     $sql .= ', ' . $sourceCol;
                     $placeholders[] = '?';
                 }
             }
         }
         foreach ($class->fieldNames as $field) {
             if (array_key_exists($field, $fields)) {
                 continue;
             }
             if ($class->isInheritanceTypeJoined() && $class->isInheritedField($field) && !$class->isIdentifier($field)) {
                 continue;
             }
             $type = Type::getType($class->fieldMappings[$field]['type']);
             $placeholders[] = !empty($class->fieldMappings[$field]['requireSQLConversion']) ? $type->convertToDatabaseValueSQL('?', $this->platform) : '?';
             $sql .= ', ' . $class->getQuotedColumnName($field, $this->platform);
         }
         if ($class->isInheritanceTypeJoined() && $class->rootEntityName == $class->name || $class->isInheritanceTypeSingleTable()) {
             $sql .= ', ' . $class->discriminatorColumn['name'];
             $placeholders[] = '?';
         }
         $sql .= ") VALUES (" . implode(", ", $placeholders) . ")";
         $this->insertRevisionSQL[$class->name] = $sql;
     }
     return $this->insertRevisionSQL[$class->name];
 }
开发者ID:fatihkahveci,项目名称:EntityAudit,代码行数:44,代码来源:LogRevisionsListener.php

示例3: _gatherColumn

 /**
  * Creates a column definition as required by the DBAL from an ORM field mapping definition.
  *
  * @param ClassMetadata $class The class that owns the field mapping.
  * @param array $mapping The field mapping.
  * @param Table $table
  * @return array The portable column definition as required by the DBAL.
  */
 private function _gatherColumn($class, array $mapping, $table)
 {
     $columnName = $class->getQuotedColumnName($mapping['fieldName'], $this->_platform);
     $columnType = $mapping['type'];
     $options = array();
     $options['length'] = isset($mapping['length']) ? $mapping['length'] : null;
     $options['notnull'] = isset($mapping['nullable']) ? !$mapping['nullable'] : true;
     if ($class->isInheritanceTypeSingleTable() && count($class->parentClasses) > 0) {
         $options['notnull'] = false;
     }
     $options['platformOptions'] = array();
     $options['platformOptions']['version'] = $class->isVersioned && $class->versionField == $mapping['fieldName'] ? true : false;
     if (strtolower($columnType) == 'string' && $options['length'] === null) {
         $options['length'] = 255;
     }
     if (isset($mapping['precision'])) {
         $options['precision'] = $mapping['precision'];
     }
     if (isset($mapping['scale'])) {
         $options['scale'] = $mapping['scale'];
     }
     if (isset($mapping['default'])) {
         $options['default'] = $mapping['default'];
     }
     if (isset($mapping['columnDefinition'])) {
         $options['columnDefinition'] = $mapping['columnDefinition'];
     }
     if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() == array($mapping['fieldName'])) {
         $options['autoincrement'] = true;
     }
     if ($class->isInheritanceTypeJoined() && $class->name != $class->rootEntityName) {
         $options['autoincrement'] = false;
     }
     if ($table->hasColumn($columnName)) {
         // required in some inheritance scenarios
         $table->changeColumn($columnName, $options);
     } else {
         $table->addColumn($columnName, $columnType, $options);
     }
     $isUnique = isset($mapping['unique']) ? $mapping['unique'] : false;
     if ($isUnique) {
         $table->addUniqueIndex(array($columnName));
     }
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:52,代码来源:SchemaTool.php

示例4: _generateStaticSql

 /**
  * Generates any static SQL strings for a class and stores them in the descriptor.
  *
  * @param ClassMetadata $class
  */
 private function _generateStaticSql($class)
 {
     // Generate INSERT SQL
     $columns = $values = array();
     if ($class->inheritanceType == ClassMetadata::INHERITANCE_TYPE_JOINED) {
         foreach ($class->reflFields as $name => $field) {
             if (isset($class->fieldMappings[$name]['inherited']) && !isset($class->fieldMappings[$name]['id']) || isset($class->inheritedAssociationFields[$name])) {
                 continue;
             }
             if (isset($class->associationMappings[$name])) {
                 $assoc = $class->associationMappings[$name];
                 if ($assoc->isOneToOne() && $assoc->isOwningSide) {
                     foreach ($assoc->targetToSourceKeyColumns as $sourceCol) {
                         $columns[] = $this->_targetPlatform->quoteIdentifier($sourceCol);
                         $values[] = '?';
                     }
                 }
             } else {
                 if ($class->name != $class->rootEntityName || !$class->isIdGeneratorIdentity() || $class->identifier[0] != $name) {
                     $columns[] = $this->_targetPlatform->quoteIdentifier($class->columnNames[$name]);
                     $values[] = '?';
                 }
             }
         }
     } else {
         foreach ($class->reflFields as $name => $field) {
             if (isset($class->associationMappings[$name])) {
                 $assoc = $class->associationMappings[$name];
                 if ($assoc->isOwningSide && $assoc->isOneToOne()) {
                     foreach ($assoc->targetToSourceKeyColumns as $sourceCol) {
                         $columns[] = $this->_targetPlatform->quoteIdentifier($sourceCol);
                         $values[] = '?';
                     }
                 }
             } else {
                 if ($class->generatorType != ClassMetadata::GENERATOR_TYPE_IDENTITY || $class->identifier[0] != $name) {
                     $columns[] = $this->_targetPlatform->quoteIdentifier($class->columnNames[$name]);
                     $values[] = '?';
                 }
             }
         }
     }
     if ($class->isInheritanceTypeSingleTable() || $class->isInheritanceTypeJoined() && $class->name == $class->rootEntityName) {
         $columns[] = $class->discriminatorColumn['name'];
         $values[] = '?';
     }
     $class->insertSql = 'INSERT INTO ' . $this->_targetPlatform->quoteIdentifier($class->primaryTable['name']) . ' (' . implode(', ', $columns) . ') ' . 'VALUES (' . implode(', ', $values) . ')';
 }
开发者ID:jackbravo,项目名称:doctrine,代码行数:53,代码来源:ClassMetadataFactory.php


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