當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。