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


PHP ClassMetadata::getTableName方法代码示例

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


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

示例1: testEntityTableNameAndInheritance

    /**
     * @depends testLoadMapping
     * @param ClassMetadata $class
     */
    public function testEntityTableNameAndInheritance($class)
    {
        $this->assertEquals('cms_users', $class->getTableName());
        $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $class->inheritanceType);

        return $class;
    }
开发者ID:naderman,项目名称:doctrine2,代码行数:11,代码来源:AbstractMappingDriverTest.php

示例2: logEntityChange

 /**
  * @param $action
  * @param \Doctrine\ORM\Mapping\ClassMetadata $meta
  * @param $entity
  */
 private function logEntityChange($action, \Doctrine\ORM\Mapping\ClassMetadata $meta, $entity)
 {
     $userToken = $this->container->get('security.context')->getToken();
     if (null !== $userToken) {
         $this->logger->info('Entity "' . $meta->getTableName() . '" with id: ' . $meta->getFieldValue($entity, $meta->getSingleIdentifierFieldName()) . ' ' . $action . ' by: ' . $this->container->get('security.context')->getToken()->getUsername());
     }
 }
开发者ID:binaryfr3ak,项目名称:sfitixi,代码行数:12,代码来源:EntityChangeListener.php

示例3: mapTranslation

 private function mapTranslation(ClassMetadata $classMetadata)
 {
     if (!$classMetadata->hasAssociation('translatable')) {
         $classMetadata->mapManyToOne(['fieldName' => 'translatable', 'inversedBy' => 'translations', 'joinColumns' => [['name' => 'translatable_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], 'targetEntity' => substr($classMetadata->name, 0, -11)]);
     }
     $name = $classMetadata->getTableName() . '_unique_translation';
     if (!$this->hasUniqueTranslationConstraint($classMetadata, $name)) {
         $classMetadata->setPrimaryTable(['uniqueConstraints' => [['name' => $name, 'columns' => ['translatable_id', 'locale']]]]);
     }
 }
开发者ID:nvdnkpr,项目名称:DoctrineBehaviors,代码行数:10,代码来源:TranslatableListener.php

示例4: guardFieldNamesConsistency

 private function guardFieldNamesConsistency(ClassMetadata $reference, ClassMetadata $redundancy)
 {
     $referenceFields = $reference->fieldNames;
     $redundancyFields = $redundancy->fieldNames;
     foreach (array_intersect_key($referenceFields, $redundancyFields) as $key => $val) {
         if ($referenceFields[$key] != $redundancyFields[$key]) {
             throw new Exception\LogicException(sprintf('Field name "%s" changed on table "%s"', $key, $redundancy->getTableName()));
         }
     }
 }
开发者ID:rezzza,项目名称:doctrine-schema-multi-mapping,代码行数:10,代码来源:MetadataMerger.php

示例5: __construct

 /**
  * @param \Doctrine\ORM\Persisters\Entity\EntityPersister $persister The entity persister to cache.
  * @param \Doctrine\ORM\Cache\Region                      $region    The entity cache region.
  * @param \Doctrine\ORM\EntityManagerInterface            $em        The entity manager.
  * @param \Doctrine\ORM\Mapping\ClassMetadata             $class     The entity metadata.
  */
 public function __construct(EntityPersister $persister, Region $region, EntityManagerInterface $em, ClassMetadata $class)
 {
     $configuration = $em->getConfiguration();
     $cacheConfig = $configuration->getSecondLevelCacheConfiguration();
     $cacheFactory = $cacheConfig->getCacheFactory();
     $this->class = $class;
     $this->region = $region;
     $this->persister = $persister;
     $this->cache = $em->getCache();
     $this->regionName = $region->getName();
     $this->uow = $em->getUnitOfWork();
     $this->metadataFactory = $em->getMetadataFactory();
     $this->cacheLogger = $cacheConfig->getCacheLogger();
     $this->timestampRegion = $cacheFactory->getTimestampRegion();
     $this->hydrator = $cacheFactory->buildEntityHydrator($em, $class);
     $this->timestampKey = new TimestampCacheKey($this->class->getTableName());
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:23,代码来源:AbstractEntityPersister.php

示例6: _getSelectSingleEntitySql

 /**
  * Gets the SELECT SQL to select a single entity by a set of field criteria.
  *
  * @param array $criteria
  * @return string The SQL.
  * @todo Quote identifier.
  */
 protected function _getSelectSingleEntitySql(array $criteria)
 {
     $columnList = '';
     foreach ($this->_class->columnNames as $column) {
         if ($columnList != '') {
             $columnList .= ', ';
         }
         $columnList .= $column;
     }
     $conditionSql = '';
     foreach ($criteria as $field => $value) {
         if ($conditionSql != '') {
             $conditionSql .= ' AND ';
         }
         $conditionSql .= $this->_class->columnNames[$field] . ' = ?';
     }
     return 'SELECT ' . $columnList . ' FROM ' . $this->_class->getTableName() . ' WHERE ' . $conditionSql;
 }
开发者ID:jackbravo,项目名称:doctrine,代码行数:25,代码来源:StandardEntityPersister.php

示例7: update

 /**
  * @param object $entity
  * @return int
  * @throws \Doctrine\ORM\Mapping\MappingException
  */
 public function update($entity)
 {
     $identifiers = [];
     $types = ['id' => \PDO::PARAM_INT];
     foreach ($this->metaData->getIdentifierColumnNames() as $columnName) {
         $fieldName = $this->metaData->getFieldForColumn($columnName);
         $value = $this->metaData->getFieldValue($entity, $fieldName);
         $identifiers[$columnName] = $value;
     }
     $updateSet = [];
     foreach ($this->metaData->getColumnNames() as $columnName) {
         if (isset($identifiers[$columnName])) {
             continue;
         }
         $fieldName = $this->metaData->getFieldForColumn($columnName);
         $typeName = $this->metaData->getTypeOfColumn($fieldName);
         $type = \Doctrine\DBAL\Types\Type::getType($typeName);
         $value = $type->convertToDatabaseValue($entity->{$fieldName}, $this->em->getConnection()->getDatabasePlatform());
         $types[$columnName] = $type->getBindingType();
         $updateSet[$columnName] = $value;
     }
     return $this->em->getConnection()->update($this->metaData->getTableName(), $updateSet, $identifiers, $types);
 }
开发者ID:lynx,项目名称:lynx,代码行数:28,代码来源:DBAL.php

示例8: deleteOne

 /**
  * @param mixed $id
  * @return int
  */
 public function deleteOne($id)
 {
     return $this->createQueryBuilder()->delete($this->metaData->getTableName())->where('id = :id')->setParameter('id', $id)->execute();
 }
开发者ID:lynx,项目名称:lynx,代码行数:8,代码来源:Repository.php

示例9: getTableName

 /**
  * Get table name.
  *
  * @param ClassMetadata $metadata
  *
  * @return string
  */
 private function getTableName(ClassMetadata $metadata)
 {
     return strtolower($metadata->getTableName());
 }
开发者ID:bigz,项目名称:datatablesbundle,代码行数:11,代码来源:DatatableQuery.php

示例10: _gatherRelationJoinColumns

 /**
  * Gather columns and fk constraints that are required for one part of relationship.
  *
  * @param array $joinColumns
  * @param \Doctrine\DBAL\Schema\Table $theJoinTable
  * @param ClassMetadata $class
  * @param \Doctrine\ORM\Mapping\AssociationMapping $mapping
  * @param array $primaryKeyColumns
  * @param array $uniqueConstraints
  */
 private function _gatherRelationJoinColumns($joinColumns, $theJoinTable, $class, $mapping, &$primaryKeyColumns, &$uniqueConstraints)
 {
     $localColumns = array();
     $foreignColumns = array();
     $fkOptions = array();
     foreach ($joinColumns as $joinColumn) {
         $columnName = $joinColumn['name'];
         $referencedFieldName = $class->getFieldName($joinColumn['referencedColumnName']);
         if (!$class->hasField($referencedFieldName)) {
             throw new \Doctrine\ORM\ORMException("Column name `" . $joinColumn['referencedColumnName'] . "` referenced for relation from " . $mapping['sourceEntity'] . " towards " . $mapping['targetEntity'] . " does not exist.");
         }
         $primaryKeyColumns[] = $columnName;
         $localColumns[] = $columnName;
         $foreignColumns[] = $joinColumn['referencedColumnName'];
         if (!$theJoinTable->hasColumn($joinColumn['name'])) {
             // Only add the column to the table if it does not exist already.
             // It might exist already if the foreign key is mapped into a regular
             // property as well.
             $fieldMapping = $class->getFieldMapping($referencedFieldName);
             $columnDef = null;
             if (isset($joinColumn['columnDefinition'])) {
                 $columnDef = $joinColumn['columnDefinition'];
             } else {
                 if (isset($fieldMapping['columnDefinition'])) {
                     $columnDef = $fieldMapping['columnDefinition'];
                 }
             }
             $columnOptions = array('notnull' => false, 'columnDefinition' => $columnDef);
             if (isset($joinColumn['nullable'])) {
                 $columnOptions['notnull'] = !$joinColumn['nullable'];
             }
             if ($fieldMapping['type'] == "string") {
                 $columnOptions['length'] = $fieldMapping['length'];
             } else {
                 if ($fieldMapping['type'] == "decimal") {
                     $columnOptions['scale'] = $fieldMapping['scale'];
                     $columnOptions['precision'] = $fieldMapping['precision'];
                 }
             }
             $theJoinTable->addColumn($columnName, $class->getTypeOfColumn($joinColumn['referencedColumnName']), $columnOptions);
         }
         if (isset($joinColumn['unique']) && $joinColumn['unique'] == true) {
             $uniqueConstraints[] = array('columns' => array($columnName));
         }
         if (isset($joinColumn['onUpdate'])) {
             $fkOptions['onUpdate'] = $joinColumn['onUpdate'];
         }
         if (isset($joinColumn['onDelete'])) {
             $fkOptions['onDelete'] = $joinColumn['onDelete'];
         }
     }
     $theJoinTable->addUnnamedForeignKeyConstraint($class->getTableName(), $localColumns, $foreignColumns, $fkOptions);
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:63,代码来源:SchemaTool.php

示例11: initializeExtendedFieldsOptions

 /**
  * Initialize extended field options by field.
  *
  * @param ClassMetadata $classMetadata
  */
 protected function initializeExtendedFieldsOptions(ClassMetadata $classMetadata)
 {
     $configManager = $this->getConfigManager();
     $className = $classMetadata->getName();
     $tableName = $classMetadata->getTableName();
     foreach ($classMetadata->getFieldNames() as $fieldName) {
         if ($configManager->hasConfig($className, $fieldName)) {
             $columnName = $classMetadata->getColumnName($fieldName);
             $options = $this->getExtendedFieldOptions($className, $fieldName);
             if (!empty($options['extend']['is_extend'])) {
                 $this->extendedFieldOptions[$tableName][$columnName] = $options;
             }
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:20,代码来源:DumpMigrationsCommand.php

示例12: getFromClause

 private function getFromClause(ClassMetadata $metadataActivity, ClassMetadata $metadataPerson)
 {
     $associationMapping = $metadataActivity->getAssociationMapping('person');
     return $metadataActivity->getTableName() . ' JOIN ' . $metadataPerson->getTableName() . ' ON ' . $metadataPerson->getTableName() . '.' . $associationMapping['joinColumns'][0]['referencedColumnName'] . ' = ' . $associationMapping['joinColumns'][0]['name'];
 }
开发者ID:Chill-project,项目名称:Activity,代码行数:5,代码来源:TimelineActivityProvider.php

示例13: __construct

 public function __construct(array $request, EntityRepository $repository, ClassMetadata $metadata, EntityManager $em, $serializer, $serverSideControl)
 {
     $this->em = $em;
     $this->request = $request;
     $this->repository = $repository;
     $this->metadata = $metadata;
     $this->serializer = $serializer;
     $this->serverSideControl = $serverSideControl;
     $this->tableName = Container::camelize($metadata->getTableName());
     $this->defaultJoinType = self::JOIN_INNER;
     $this->defaultResultType = self::RESULT_ARRAY;
     $this->notAvailableFallback = self::NOT_AVAILABLE;
     if ($this->serverSideControl === false) {
         if (sizeof($this->request) == 0 || count(array_diff(array('iColumns', 'sEcho', 'sSearch', 'iDisplayStart', 'iDisplayLength'), array_keys($this->request)))) {
             throw new \Exception('Unable to recognize a datatables.js valid request.');
         }
         $this->setParameters();
     }
     $this->qb = $em->createQueryBuilder();
     $identifiers = $this->metadata->getIdentifierFieldNames();
     $this->rootEntityIdentifier = array_shift($identifiers);
     // Default vars to inject into 'aoCustomVars' when using server side control
     $this->aoCustomVars = array();
     if (sizeof($this->request) > 0) {
         $this->echo = isset($this->request['sEcho']) ? $this->request['sEcho'] : '';
         $this->search = isset($this->request['sSearch']) ? $this->request['sSearch'] : '';
         $this->offset = isset($this->request['iDisplayStart']) ? $this->request['iDisplayStart'] : 0;
         $this->amount = isset($this->request['iDisplayLength']) ? $this->request['iDisplayLength'] : 10000;
         $this->dtRowIdPrefix = isset($this->request[self::CUSTOM_VAR_ROW_ID_PREFIX]) ? $this->request[self::CUSTOM_VAR_ROW_ID_PREFIX] : '';
     }
     $this->offset = !is_null($this->offset) ? $this->offset : 0;
     // fallback value
     $this->amount = !is_null($this->amount) ? $this->amount : 10000;
     // fallback value
 }
开发者ID:rheck,项目名称:datatable-bundle,代码行数:35,代码来源:Datatable.php

示例14: getOwningTable

 /**
  * Gets the name of the table that owns the column the given field is mapped to.
  *
  * The default implementation in BasicEntityPersister always returns the name
  * of the table the entity type of this persister is mapped to, since an entity
  * is always persisted to a single table with a BasicEntityPersister.
  *
  * @param string $fieldName The field name.
  * @return string The table name.
  */
 public function getOwningTable($fieldName)
 {
     return $this->_class->getTableName();
 }
开发者ID:ncking,项目名称:doctrine2,代码行数:14,代码来源:BasicEntityPersister.php

示例15: setAssociations

 /**
  * Set selectFields[], joins[] and allFields[] for associations.
  *
  * @param array         $fields   Association field array
  * @param int           $i        Numeric key
  * @param ClassMetadata $metadata A ClassMetadata instance
  *
  * @return DatatableData
  */
 private function setAssociations($fields, $i, $metadata)
 {
     $field = $fields[$i];
     if ($metadata->hasAssociation($field) === true) {
         $targetClass = $metadata->getAssociationTargetClass($field);
         $targetMeta = $this->em->getClassMetadata($targetClass);
         $targetTableName = $targetMeta->getTableName();
         $targetIdentifiers = $targetMeta->getIdentifierFieldNames();
         $targetRootIdentifier = array_shift($targetIdentifiers);
         if (!array_key_exists($targetTableName, $this->selectFields)) {
             $this->selectFields[$targetTableName][] = $targetRootIdentifier;
             $this->addJoin(array('source' => $metadata->getTableName() . '.' . $field, 'target' => $targetTableName));
         }
         $i++;
         $this->setAssociations($fields, $i, $targetMeta);
     } else {
         $targetTableName = $metadata->getTableName();
         $targetIdentifiers = $metadata->getIdentifierFieldNames();
         $targetRootIdentifier = array_shift($targetIdentifiers);
         if ($field !== $targetRootIdentifier) {
             array_push($this->selectFields[$targetTableName], $field);
         }
         $this->allFields[] = $targetTableName . '.' . $field;
     }
     return $this;
 }
开发者ID:dutchbridge,项目名称:datatablebundle,代码行数:35,代码来源:DatatableData.php


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