Ouzo\Db\ModelQueryBuilderHelper::createModelJoins PHP Метод

createModelJoins() публичный статический Метод

public static createModelJoins ( $fromTable, RelationWithAlias[] $relationWithAliases, $type, $on ) : ModelJoin[]
$fromTable
$relationWithAliases RelationWithAlias[]
$type
$on
Результат ModelJoin[]
    public static function createModelJoins($fromTable, $relationWithAliases, $type, $on)
    {
        $result = array();
        $field = '';
        $table = $fromTable;
        $fetch = true;
        foreach ($relationWithAliases as $relationWithAlias) {
            $relation = $relationWithAlias->relation;
            $field = $field ? $field . '->' . $relation->getName() : $relation->getName();
            $fetch = $fetch && !$relation->isCollection();
            $modelJoin = new ModelJoin($field, $table, $relation, $relationWithAlias->alias, $type, $on, $fetch);
            $table = $modelJoin->alias();
            $result[] = $modelJoin;
        }
        return $result;
    }

Usage Example

Пример #1
0
 private function createModelJoins($relationSelector, $aliases, $type, $on)
 {
     $relations = ModelQueryBuilderHelper::extractRelations($this->_model, $relationSelector);
     $relationWithAliases = ModelQueryBuilderHelper::associateRelationsWithAliases($relations, $aliases);
     return ModelQueryBuilderHelper::createModelJoins($this->getModelAliasOrTable(), $relationWithAliases, $type, $on);
 }