本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadata::getColumnNames方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::getColumnNames方法的具体用法?PHP ClassMetadata::getColumnNames怎么用?PHP ClassMetadata::getColumnNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Mapping\ClassMetadata
的用法示例。
在下文中一共展示了ClassMetadata::getColumnNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFieldsFromClass
protected function addFieldsFromClass(Doctrine\ORM\Mapping\ClassMetadata $class, $alias, $columnAliasMap)
{
foreach ($class->getColumnNames() as $columnName) {
$propertyName = $class->getFieldName($columnName);
if ($class->isInheritedField($propertyName)) {
continue;
}
$columnAlias = $this->platform->getSQLResultCasing($columnAliasMap[$columnName]);
if (isset($this->fieldMappings[$columnAlias])) {
throw new \InvalidArgumentException("The column '{$columnName}' conflicts with another column in the mapper.");
}
$this->addFieldResult($alias, $columnAlias, $propertyName, $class->getName());
}
}
示例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);
}
示例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);
}