本文整理汇总了PHP中Doctrine\ORM\Mapping\QuoteStrategy::getIdentifierColumnNames方法的典型用法代码示例。如果您正苦于以下问题:PHP QuoteStrategy::getIdentifierColumnNames方法的具体用法?PHP QuoteStrategy::getIdentifierColumnNames怎么用?PHP QuoteStrategy::getIdentifierColumnNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Mapping\QuoteStrategy
的用法示例。
在下文中一共展示了QuoteStrategy::getIdentifierColumnNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.
*
* @return void
*/
public function delete($entity)
{
$class = $this->class;
$em = $this->em;
$identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
$tableName = $this->quoteStrategy->getTableName($class, $this->platform);
$idColumns = $this->quoteStrategy->getIdentifierColumnNames($class, $this->platform);
$id = array_combine($idColumns, $identifier);
$types = array_map(function ($identifier) use ($class, $em) {
if (isset($class->fieldMappings[$identifier])) {
return $class->fieldMappings[$identifier]['type'];
}
$targetMapping = $em->getClassMetadata($class->associationMappings[$identifier]['targetEntity']);
if (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])) {
return $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];
}
if (isset($targetMapping->associationMappings[$targetMapping->identifier[0]])) {
$types[] = $targetMapping->associationMappings[$targetMapping->identifier[0]]['type'];
}
throw ORMException::unrecognizedField($targetMapping->identifier[0]);
}, $class->identifier);
$this->deleteJoinTableRecords($identifier);
$this->conn->delete($tableName, $id, $types);
}
示例2: walkCollectionMemberExpression
/**
* {@inheritdoc}
*/
public function walkCollectionMemberExpression($collMemberExpr)
{
$sql = $collMemberExpr->not ? 'NOT ' : '';
$sql .= 'EXISTS (SELECT 1 FROM ';
$entityExpr = $collMemberExpr->entityExpression;
$collPathExpr = $collMemberExpr->collectionValuedPathExpression;
$fieldName = $collPathExpr->field;
$dqlAlias = $collPathExpr->identificationVariable;
$class = $this->queryComponents[$dqlAlias]['metadata'];
switch (true) {
// InputParameter
case $entityExpr instanceof AST\InputParameter:
$dqlParamKey = $entityExpr->name;
$entitySql = '?';
break;
// SingleValuedAssociationPathExpression | IdentificationVariable
// SingleValuedAssociationPathExpression | IdentificationVariable
case $entityExpr instanceof AST\PathExpression:
$entitySql = $this->walkPathExpression($entityExpr);
break;
default:
throw new \BadMethodCallException("Not implemented");
}
$assoc = $class->associationMappings[$fieldName];
if ($assoc['type'] == ClassMetadata::ONE_TO_MANY) {
$targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
$targetTableAlias = $this->getSQLTableAlias($targetClass->getTableName());
$sourceTableAlias = $this->getSQLTableAlias($class->getTableName(), $dqlAlias);
$sql .= $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' ' . $targetTableAlias . ' WHERE ';
$owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']];
$sqlParts = array();
foreach ($owningAssoc['targetToSourceKeyColumns'] as $targetColumn => $sourceColumn) {
$targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $this->platform);
$sqlParts[] = $sourceTableAlias . '.' . $targetColumn . ' = ' . $targetTableAlias . '.' . $sourceColumn;
}
foreach ($this->quoteStrategy->getIdentifierColumnNames($targetClass, $this->platform) as $targetColumnName) {
if (isset($dqlParamKey)) {
$this->parserResult->addParameterMapping($dqlParamKey, $this->sqlParamIndex++);
}
$sqlParts[] = $targetTableAlias . '.' . $targetColumnName . ' = ' . $entitySql;
}
$sql .= implode(' AND ', $sqlParts);
} else {
// many-to-many
$targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
$owningAssoc = $assoc['isOwningSide'] ? $assoc : $targetClass->associationMappings[$assoc['mappedBy']];
$joinTable = $owningAssoc['joinTable'];
// SQL table aliases
$joinTableAlias = $this->getSQLTableAlias($joinTable['name']);
$targetTableAlias = $this->getSQLTableAlias($targetClass->getTableName());
$sourceTableAlias = $this->getSQLTableAlias($class->getTableName(), $dqlAlias);
// join to target table
$sql .= $this->quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $this->platform) . ' ' . $joinTableAlias . ' INNER JOIN ' . $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' ' . $targetTableAlias . ' ON ';
// join conditions
$joinColumns = $assoc['isOwningSide'] ? $joinTable['inverseJoinColumns'] : $joinTable['joinColumns'];
$joinSqlParts = array();
foreach ($joinColumns as $joinColumn) {
$targetColumn = $this->quoteStrategy->getColumnName($targetClass->fieldNames[$joinColumn['referencedColumnName']], $targetClass, $this->platform);
$joinSqlParts[] = $joinTableAlias . '.' . $joinColumn['name'] . ' = ' . $targetTableAlias . '.' . $targetColumn;
}
$sql .= implode(' AND ', $joinSqlParts);
$sql .= ' WHERE ';
$joinColumns = $assoc['isOwningSide'] ? $joinTable['joinColumns'] : $joinTable['inverseJoinColumns'];
$sqlParts = array();
foreach ($joinColumns as $joinColumn) {
$targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$joinColumn['referencedColumnName']], $class, $this->platform);
$sqlParts[] = $joinTableAlias . '.' . $joinColumn['name'] . ' = ' . $sourceTableAlias . '.' . $targetColumn;
}
foreach ($this->quoteStrategy->getIdentifierColumnNames($targetClass, $this->platform) as $targetColumnName) {
if (isset($dqlParamKey)) {
$this->parserResult->addParameterMapping($dqlParamKey, $this->sqlParamIndex++);
}
$sqlParts[] = $targetTableAlias . '.' . $targetColumnName . ' = ' . $entitySql;
}
$sql .= implode(' AND ', $sqlParts);
}
return $sql . ')';
}
示例3: 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->quoteStrategy->getIdentifierColumnNames($this->_class, $this->_platform), $identifier);
$this->_conn->delete($this->quoteStrategy->getTableName($this->_class, $this->_platform), $id);
}