當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClassMetadata::getIdentifierColumnNames方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\Mapping\ClassMetadata::getIdentifierColumnNames方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassMetadata::getIdentifierColumnNames方法的具體用法?PHP ClassMetadata::getIdentifierColumnNames怎麽用?PHP ClassMetadata::getIdentifierColumnNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::getIdentifierColumnNames方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: delete

 /**
  * Deletes a managed entity.
  *
  * The entity to delete must be managed and have a persistent identifier.
  * The deletion happens instantaneously.
  *
  * Subclasses may override this method to customize the semantics of entity deletion.
  *
  * @param object $entity The entity to delete.
  */
 public function delete($entity)
 {
     $identifier = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
     $this->deleteJoinTableRecords($identifier);
     $id = array_combine($this->_class->getIdentifierColumnNames(), $identifier);
     $this->_conn->delete($this->_class->getQuotedTableName($this->_platform), $id);
 }
開發者ID:jfkz,項目名稱:aquarel-cms,代碼行數:17,代碼來源:BasicEntityPersister.php

示例2: VALUES

 function it_massively_persists_pending_versions($versionBuilder, $versionManager, $normalizer, $connection, $entityManager, $tableNameBuilder, ClassMetadata $versionMetadata, ProductInterface $product1, ProductInterface $product2, Version $pendingVersion1, Version $pendingVersion2, \DateTime $date1, \DateTime $date2)
 {
     $products = [$product1, $product2];
     $date1->format(\DateTime::ISO8601)->willReturn('2014-07-16T10:20:36+02:00');
     $date2->format(\DateTime::ISO8601)->willReturn('2014-07-16T10:20:37+02:00');
     $versionManager->getUsername()->willReturn('julia');
     $versionManager->getContext()->willReturn('CSV Import');
     $normalizedProduct1 = ['sku' => 'sku-001', 'name' => 'my product 1'];
     $normalizedProduct2 = ['sku' => 'sku-002', 'name' => 'my product 2'];
     $normalizer->normalize($product1, 'csv', ['versioning' => true])->willReturn($normalizedProduct1);
     $normalizer->normalize($product2, 'csv', ['versioning' => true])->willReturn($normalizedProduct2);
     $tableNameBuilder->getTableName('VersionClass')->willReturn('version_table');
     $versionMetadata->getColumnNames()->willReturn(['id', 'author', 'changeset', 'snapshot', 'resource_name', 'resource_id', 'context', 'logged_at', 'pending']);
     $versionMetadata->getFieldName('author')->willReturn('author');
     $versionMetadata->getFieldName('changeset')->willReturn('changeset');
     $versionMetadata->getFieldName('snapshot')->willReturn('snapshot');
     $versionMetadata->getFieldName('resource_name')->willReturn('resourceName');
     $versionMetadata->getFieldName('resource_id')->willReturn('resourceId');
     $versionMetadata->getFieldName('context')->willReturn('context');
     $versionMetadata->getFieldName('logged_at')->willReturn('loggedAt');
     $versionMetadata->getFieldName('pending')->willReturn('pending');
     $versionMetadata->getIdentifierColumnNames()->willReturn(['id']);
     $versionMetadata->getFieldValue($pendingVersion1, 'author')->willReturn('julia');
     $versionMetadata->getFieldValue($pendingVersion1, 'context')->willReturn('CSV Import');
     $versionMetadata->getFieldValue($pendingVersion1, 'changeset')->willReturn(serialize($normalizedProduct1));
     $versionMetadata->getFieldValue($pendingVersion1, 'snapshot')->willReturn(null);
     $versionMetadata->getFieldValue($pendingVersion1, 'resourceName')->willReturn('ProductClass');
     $versionMetadata->getFieldValue($pendingVersion1, 'resourceId')->willReturn('myprod1');
     $versionMetadata->getFieldValue($pendingVersion1, 'loggedAt')->willReturn($date1);
     $versionMetadata->getFieldValue($pendingVersion1, 'pending')->willReturn(true);
     $versionMetadata->getFieldValue($pendingVersion2, 'author')->willReturn('julia');
     $versionMetadata->getFieldValue($pendingVersion2, 'context')->willReturn('CSV Import');
     $versionMetadata->getFieldValue($pendingVersion2, 'changeset')->willReturn(serialize($normalizedProduct2));
     $versionMetadata->getFieldValue($pendingVersion2, 'snapshot')->willReturn(null);
     $versionMetadata->getFieldValue($pendingVersion2, 'resourceName')->willReturn('ProductClass');
     $versionMetadata->getFieldValue($pendingVersion2, 'resourceId')->willReturn('myprod2');
     $versionMetadata->getFieldValue($pendingVersion2, 'loggedAt')->willReturn($date2);
     $versionMetadata->getFieldValue($pendingVersion2, 'pending')->willReturn(true);
     $entityManager->getClassMetadata('VersionClass')->willReturn($versionMetadata);
     $versionBuilder->createPendingVersion($product1, 'julia', $normalizedProduct1, 'CSV Import')->willReturn($pendingVersion1);
     $versionBuilder->createPendingVersion($product2, 'julia', $normalizedProduct2, 'CSV Import')->willReturn($pendingVersion2);
     $connection->executeQuery('INSERT INTO version_table' . ' (author,changeset,snapshot,resource_name,resource_id,context,logged_at,pending)' . ' VALUES (?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?)', ['julia', 'a:2:{s:3:"sku";s:7:"sku-001";s:4:"name";s:12:"my product 1";}', null, 'ProductClass', 'myprod1', 'CSV Import', '2014-07-16 08:20:36', true, 'julia', 'a:2:{s:3:"sku";s:7:"sku-002";s:4:"name";s:12:"my product 2";}', null, 'ProductClass', 'myprod2', 'CSV Import', '2014-07-16 08:20:37', true])->shouldBeCalled();
     $this->persistPendingVersions($products);
 }
開發者ID:javiersantos,項目名稱:pim-community-dev,代碼行數:44,代碼來源:PendingMassPersisterSpec.php

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

示例4: getDefiningClass

 /**
  * Get the class metadata that is responsible for the definition of the referenced column name.
  *
  * Previously this was a simple task, but with DDC-117 this problem is actually recursive. If its
  * not a simple field, go through all identifier field names that are associations recursivly and
  * find that referenced column name.
  *
  * TODO: Is there any way to make this code more pleasing?
  *
  * @param ClassMetadata $class
  * @param string $referencedColumnName
  * @return array(ClassMetadata, referencedFieldName)
  */
 private function getDefiningClass($class, $referencedColumnName)
 {
     $referencedFieldName = $class->getFieldName($referencedColumnName);
     if ($class->hasField($referencedFieldName)) {
         return array($class, $referencedFieldName);
     } else {
         if (in_array($referencedColumnName, $class->getIdentifierColumnNames())) {
             // it seems to be an entity as foreign key
             foreach ($class->getIdentifierFieldNames() as $fieldName) {
                 if ($class->hasAssociation($fieldName) && $class->getSingleAssociationJoinColumnName($fieldName) == $referencedColumnName) {
                     return $this->getDefiningClass($this->em->getClassMetadata($class->associationMappings[$fieldName]['targetEntity']), $class->getSingleAssociationReferencedJoinColumnName($fieldName));
                 }
             }
         }
     }
     return null;
 }
開發者ID:Herriniaina,項目名稱:iVarotra,代碼行數:30,代碼來源:SchemaTool.php

示例5: delete

 /**
  * Deletes an entity.
  *
  * @param object $entity The entity to delete.
  */
 public function delete($entity)
 {
     $id = array_combine($this->_class->getIdentifierColumnNames(), $this->_em->getUnitOfWork()->getEntityIdentifier($entity));
     $this->_conn->delete($this->_class->table['name'], $id);
 }
開發者ID:poulikov,項目名稱:readlater,代碼行數:10,代碼來源:StandardEntityPersister.php


注:本文中的Doctrine\ORM\Mapping\ClassMetadata::getIdentifierColumnNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。