Final Class Yiisoft\ActiveRecord\JoinWith
| Inheritance | Yiisoft\ActiveRecord\JoinWith |
|---|
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $relations | array | Yiisoft\ActiveRecord\JoinWith |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ActiveRecord\JoinWith | |
| getJoinType() | Returns the join type based on the relation name. | Yiisoft\ActiveRecord\JoinWith |
| getWith() | Returns the list of relations to be loaded, filtered according to the eagerLoading configuration. |
Yiisoft\ActiveRecord\JoinWith |
| withoutEagerLoading() | Creates a new instance without eager loading. | Yiisoft\ActiveRecord\JoinWith |
Property Details
Method Details
| public mixed __construct ( array $relations, array|boolean $eagerLoading, array|string $joinType ) | ||
| $relations | array | |
| $eagerLoading | array|boolean | |
| $joinType | array|string | |
public function __construct(
public readonly array $relations,
private array|bool $eagerLoading,
private readonly array|string $joinType,
) {}
Returns the join type based on the relation name.
| public string getJoinType ( string $name ) | ||
| $name | string |
The relation name. |
| return | string |
The real join type. |
|---|---|---|
public function getJoinType(string $name): string
{
return is_array($this->joinType)
? ($this->joinType[$name] ?? 'INNER JOIN')
: $this->joinType;
}
Returns the list of relations to be loaded, filtered according to the eagerLoading configuration.
If eagerLoading is an array, only relations whose names are present in the array will be included.
If eagerLoading is true, all relations will be included.
If eagerLoading is false, no relations will be included.
| public array getWith ( ) | ||
| return | array |
The filtered list of relations to be loaded. |
|---|---|---|
public function getWith(): array
{
if (is_array($this->eagerLoading)) {
$with = $this->relations;
foreach ($with as $name => $callback) {
if (is_int($name)) {
if (!in_array($callback, $this->eagerLoading, true)) {
unset($with[$name]);
}
} elseif (!in_array($name, $this->eagerLoading, true)) {
unset($with[$name]);
}
}
return $with;
}
return $this->eagerLoading ? $this->relations : [];
}
Creates a new instance without eager loading.
| public self withoutEagerLoading ( ) | ||
| return | self |
A new instance without eager loading. |
|---|---|---|
public function withoutEagerLoading(): self
{
$new = clone $this;
$new->eagerLoading = false;
return $new;
}
Signup or Login in order to comment.