From ac70c18d5053bed11fab870bf15cbb7963f8f167 Mon Sep 17 00:00:00 2001 From: Pavel Batanov Date: Wed, 1 Apr 2015 14:55:52 +0300 Subject: [PATCH] Check for the being owning side * Small fix do get rid of notice `undefined index 'joinTable'` as the inverse side does not declare `joinTable` at all. * Shortened access to `$classMetadata->associationMappings[$fieldName]` for read accesses to increase readability --- docs/en/cookbook/sql-table-prefixes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/cookbook/sql-table-prefixes.rst b/docs/en/cookbook/sql-table-prefixes.rst index 66a6aaa2d..fdfd4032f 100644 --- a/docs/en/cookbook/sql-table-prefixes.rst +++ b/docs/en/cookbook/sql-table-prefixes.rst @@ -45,8 +45,8 @@ appropriate autoloaders. } foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) { - if ($mapping['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY) { - $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name']; + if ($mapping['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY && $mapping['isOwningSide']) { + $mappedTableName = $mapping['joinTable']['name']; $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName; } }