protected function resolveSettingDistinctForARelationAttributeThatIsHasMany() { if ($this->modelAttributeToDataProviderAdapter->getRelationType() == RedBeanModel::HAS_MANY) { $this->resolveSetToDistinct(); } }
/** * When the attributeName is 'id', this method determines if we need to join any tables or we can just * add where clauses on the column in the base table that corresponds to the id. * @see RedBeanModelDataProvider::makeWhere * @see addWherePartByClauseInformation * */ protected static function buildJoinAndWhereForRelatedId(RedBeanModelAttributeToDataProviderAdapter $modelAttributeToDataProviderAdapter, $operatorType, $value, $whereKey, $joinTablesAdapter, &$where) { assert('is_string($operatorType)'); assert('$modelAttributeToDataProviderAdapter->getRelatedAttribute() == "id"'); assert('is_int($whereKey)'); assert('$joinTablesAdapter instanceof RedBeanModelJoinTablesQueryAdapter'); assert('is_array($where)'); //Is the relation type HAS_ONE or HAS_MANY_BELONGS_TO if ($modelAttributeToDataProviderAdapter->getRelationType() == RedBeanModel::HAS_ONE || $modelAttributeToDataProviderAdapter->getRelationType() == RedBeanModel::HAS_MANY_BELONGS_TO) { $tableAliasName = self::resolveShouldAddFromTableAndGetAliasName($modelAttributeToDataProviderAdapter, $joinTablesAdapter); self::addWherePartByClauseInformation($operatorType, $value, $where, $whereKey, $tableAliasName, $modelAttributeToDataProviderAdapter->getColumnName()); } elseif ($modelAttributeToDataProviderAdapter->getRelationType() == RedBeanModel::MANY_MANY) { self::buildJoinAndWhereForManyToManyRelatedAttribute($modelAttributeToDataProviderAdapter, $operatorType, $value, $whereKey, $joinTablesAdapter, $where); } else { self::buildJoinAndWhereForRelatedAttribute($modelAttributeToDataProviderAdapter, $operatorType, $value, $whereKey, $joinTablesAdapter, $where); } }