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


PHP MappingException::joinColumnMustPointToMappedField方法代码示例

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


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

示例1: loadManyToManyCollection

 /**
  * Loads a collection of entities of a many-to-many association.
  *
  * @param ManyToManyMapping $assoc The association mapping of the association being loaded.
  * @param object $sourceEntity The entity that owns the collection.
  * @param PersistentCollection $coll The collection to fill.
  */
 public function loadManyToManyCollection(array $assoc, $sourceEntity, PersistentCollection $coll)
 {
     $criteria = array();
     $sourceClass = $this->_em->getClassMetadata($assoc['sourceEntity']);
     $joinTableConditions = array();
     if ($assoc['isOwningSide']) {
         foreach ($assoc['relationToSourceKeyColumns'] as $relationKeyColumn => $sourceKeyColumn) {
             if (isset($sourceClass->fieldNames[$sourceKeyColumn])) {
                 $criteria[$relationKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity);
             } else {
                 throw MappingException::joinColumnMustPointToMappedField($sourceClass->name, $sourceKeyColumn);
             }
         }
     } else {
         $owningAssoc = $this->_em->getClassMetadata($assoc['targetEntity'])->associationMappings[$assoc['mappedBy']];
         // TRICKY: since the association is inverted source and target are flipped
         foreach ($owningAssoc['relationToTargetKeyColumns'] as $relationKeyColumn => $sourceKeyColumn) {
             if (isset($sourceClass->fieldNames[$sourceKeyColumn])) {
                 $criteria[$relationKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity);
             } else {
                 throw MappingException::joinColumnMustPointToMappedField($sourceClass->name, $sourceKeyColumn);
             }
         }
     }
     $sql = $this->_getSelectEntitiesSQL($criteria, $assoc);
     $stmt = $this->_conn->executeQuery($sql, array_values($criteria));
     while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $coll->hydrateAdd($this->_createEntity($result));
     }
     $stmt->closeCursor();
 }
开发者ID:jeffreiffers,项目名称:doctrine2,代码行数:38,代码来源:BasicEntityPersister.php

示例2: getManyToManyStatement

 private function getManyToManyStatement(array $assoc, $sourceEntity, $offset = null, $limit = null)
 {
     $criteria = array();
     $sourceClass = $this->_em->getClassMetadata($assoc['sourceEntity']);
     if ($assoc['isOwningSide']) {
         $quotedJoinTable = $sourceClass->getQuotedJoinTableName($assoc, $this->_platform);
         foreach ($assoc['relationToSourceKeyColumns'] as $relationKeyColumn => $sourceKeyColumn) {
             if ($sourceClass->containsForeignIdentifier) {
                 $field = $sourceClass->getFieldForColumn($sourceKeyColumn);
                 $value = $sourceClass->reflFields[$field]->getValue($sourceEntity);
                 if (isset($sourceClass->associationMappings[$field])) {
                     $value = $this->_em->getUnitOfWork()->getEntityIdentifier($value);
                     $value = $value[$this->_em->getClassMetadata($sourceClass->associationMappings[$field]['targetEntity'])->identifier[0]];
                 }
                 $criteria[$quotedJoinTable . "." . $relationKeyColumn] = $value;
             } else {
                 if (isset($sourceClass->fieldNames[$sourceKeyColumn])) {
                     $criteria[$quotedJoinTable . "." . $relationKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity);
                 } else {
                     throw MappingException::joinColumnMustPointToMappedField($sourceClass->name, $sourceKeyColumn);
                 }
             }
         }
     } else {
         $owningAssoc = $this->_em->getClassMetadata($assoc['targetEntity'])->associationMappings[$assoc['mappedBy']];
         $quotedJoinTable = $sourceClass->getQuotedJoinTableName($owningAssoc, $this->_platform);
         // TRICKY: since the association is inverted source and target are flipped
         foreach ($owningAssoc['relationToTargetKeyColumns'] as $relationKeyColumn => $sourceKeyColumn) {
             if ($sourceClass->containsForeignIdentifier) {
                 $field = $sourceClass->getFieldForColumn($sourceKeyColumn);
                 $value = $sourceClass->reflFields[$field]->getValue($sourceEntity);
                 if (isset($sourceClass->associationMappings[$field])) {
                     $value = $this->_em->getUnitOfWork()->getEntityIdentifier($value);
                     $value = $value[$this->_em->getClassMetadata($sourceClass->associationMappings[$field]['targetEntity'])->identifier[0]];
                 }
                 $criteria[$quotedJoinTable . "." . $relationKeyColumn] = $value;
             } else {
                 if (isset($sourceClass->fieldNames[$sourceKeyColumn])) {
                     $criteria[$quotedJoinTable . "." . $relationKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity);
                 } else {
                     throw MappingException::joinColumnMustPointToMappedField($sourceClass->name, $sourceKeyColumn);
                 }
             }
         }
     }
     $sql = $this->_getSelectEntitiesSQL($criteria, $assoc, 0, $limit, $offset);
     list($params, $types) = $this->expandParameters($criteria);
     return $this->_conn->executeQuery($sql, $params, $types);
 }
开发者ID:jfkz,项目名称:aquarel-cms,代码行数:49,代码来源:BasicEntityPersister.php

示例3: getManyToManyStatement

    /**
     * @param array    $assoc
     * @param object   $sourceEntity
     * @param int|null $offset
     * @param int|null $limit
     *
     * @return \Doctrine\DBAL\Driver\Statement
     *
     * @throws \Doctrine\ORM\Mapping\MappingException
     */
    private function getManyToManyStatement(array $assoc, $sourceEntity, $offset = null, $limit = null)
    {
        $sourceClass    = $this->em->getClassMetadata($assoc['sourceEntity']);
        $class          = $sourceClass;
        $association    = $assoc;
        $criteria       = array();


        if ( ! $assoc['isOwningSide']) {
            $class       = $this->em->getClassMetadata($assoc['targetEntity']);
            $association = $class->associationMappings[$assoc['mappedBy']];
        }

        $joinColumns = $assoc['isOwningSide']
            ? $association['joinTable']['joinColumns']
            : $association['joinTable']['inverseJoinColumns'];

        $quotedJoinTable = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform);

        foreach ($joinColumns as $joinColumn) {

            $sourceKeyColumn    = $joinColumn['referencedColumnName'];
            $quotedKeyColumn    = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);

            switch (true) {
                case $sourceClass->containsForeignIdentifier:
                    $field = $sourceClass->getFieldForColumn($sourceKeyColumn);
                    $value = $sourceClass->reflFields[$field]->getValue($sourceEntity);

                    if (isset($sourceClass->associationMappings[$field])) {
                        $value = $this->em->getUnitOfWork()->getEntityIdentifier($value);
                        $value = $value[$this->em->getClassMetadata($sourceClass->associationMappings[$field]['targetEntity'])->identifier[0]];
                    }

                    break;

                case isset($sourceClass->fieldNames[$sourceKeyColumn]):
                    $field = $sourceClass->fieldNames[$sourceKeyColumn];
                    $value = $sourceClass->reflFields[$field]->getValue($sourceEntity);

                    break;

                default:
                    throw MappingException::joinColumnMustPointToMappedField(
                        $sourceClass->name, $sourceKeyColumn
                    );
            }

            $criteria[$quotedJoinTable . '.' . $quotedKeyColumn] = $value;
        }

        $sql = $this->getSelectSQL($criteria, $assoc, 0, $limit, $offset);
        list($params, $types) = $this->expandParameters($criteria);

        return $this->conn->executeQuery($sql, $params, $types);
    }
开发者ID:nattaphat,项目名称:hgis,代码行数:66,代码来源:BasicEntityPersister.php


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