Example #1
0
 /**
  * @param $onTableAliasName
  * @return null|string
  */
 protected function resolveJoinsForForARelationAttributeThatIsManyToMany($onTableAliasName)
 {
     assert('is_string($onTableAliasName)');
     $relationTableName = $this->modelAttributeToDataProviderAdapter->getRelationTableName();
     $attributeTableName = $this->modelAttributeToDataProviderAdapter->getAttributeTableName();
     $relationJoiningTableAliasName = $this->joinTablesAdapter->addLeftTableAndGetAliasName($this->modelAttributeToDataProviderAdapter->getManyToManyTableName(), "id", $onTableAliasName, self::resolveForeignKey($attributeTableName));
     //if this is not the id column, then add an additional left join.
     if ($this->modelAttributeToDataProviderAdapter->getRelatedAttribute() != 'id') {
         $this->resolveSetToDistinct();
         return $this->joinTablesAdapter->addLeftTableAndGetAliasName($relationTableName, self::resolveForeignKey($relationTableName), $relationJoiningTableAliasName, 'id');
     } else {
         return $relationJoiningTableAliasName;
     }
 }