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


PHP QuoteStrategy::getIdentifierColumnNames方法代码示例

本文整理汇总了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);
    }
开发者ID:nattaphat,项目名称:hgis,代码行数:44,代码来源:BasicEntityPersister.php

示例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 . ')';
 }
开发者ID:nemekzg,项目名称:doctrine2,代码行数:81,代码来源:SqlWalker.php

示例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);
 }
开发者ID:bardascat,项目名称:blogify,代码行数:17,代码来源:BasicEntityPersister.php


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