1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +03:00
This commit is contained in:
Fabio B. Silva 2012-06-27 00:24:53 -03:00
parent 076663fe3a
commit 63580dfe26

View file

@ -1140,28 +1140,27 @@ class BasicEntityPersister
*/ */
protected function _getSelectManyToManyJoinSQL(array $manyToMany) protected function _getSelectManyToManyJoinSQL(array $manyToMany)
{ {
$conditions = array();
$association = $manyToMany;
$sourceTableAlias = $this->_getSQLTableAlias($this->_class->name);
$conditions = array(); if ( ! $manyToMany['isOwningSide']) {
$sourceTableAlias = $this->_getSQLTableAlias($this->_class->name); $targetEntity = $this->_em->getClassMetadata($manyToMany['targetEntity']);
$association = $targetEntity->associationMappings[$manyToMany['mappedBy']];
}
$association = ($manyToMany['isOwningSide']) $joinTableName = $this->quoteStrategy->getJoinTableName($association, $this->_class, $this->_platform);
? $manyToMany $joinColumns = ($manyToMany['isOwningSide'])
: $this->_em->getClassMetadata($manyToMany['targetEntity'])
->associationMappings[$manyToMany['mappedBy']];
$relationColumns = ($manyToMany['isOwningSide'])
? $association['joinTable']['inverseJoinColumns'] ? $association['joinTable']['inverseJoinColumns']
: $association['joinTable']['joinColumns']; : $association['joinTable']['joinColumns'];
$joinTableName = $this->quoteStrategy->getJoinTableName($association, $this->_class, $this->_platform); foreach ($joinColumns as $joinColumn) {
foreach ($relationColumns as $joinColumn) {
$quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform); $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
$quotedTargetColumn = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->_class, $this->_platform); $quotedTargetColumn = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->_class, $this->_platform);
$conditions[] = $sourceTableAlias . '.' . $quotedTargetColumn . ' = ' . $joinTableName . '.' . $quotedSourceColumn;
$conditions[] = $sourceTableAlias . '.' . $quotedTargetColumn . ' = ' . $joinTableName . '.' . $quotedSourceColumn;
} }
return ' INNER JOIN ' . $joinTableName . ' ON ' . implode(' AND ', $conditions); return ' INNER JOIN ' . $joinTableName . ' ON ' . implode(' AND ', $conditions);
} }
/** /**