source/Spiral/ORM/Entities/RecordSelector.php
public function load($relation, array $options = []): self
    {
        if (is_array($relation)) {
            foreach ($relation as $name => $subOption) {
                if (is_string($subOption)) {
                    //Array of relation names
                    $this->load($subOption, $options);
                } else {
                    //Multiple relations or relation with addition load options
                    $this->load($name, $subOption + $options);
                }
            }

            return $this;
        }

        //We are requesting primary loaded to pre-load nested relation
        $this->loader->loadRelation($relation, $options);

        return $this;
    }
public function load($relation, array $options = []): self
    {
        if (is_array($relation)) {
            foreach ($relation as $name => $subOption) {
                if (is_string($subOption)) {
                    //Array of relation names
                    $this->load($subOption, $options);
                } else {
                    //Multiple relations or relation with addition load options
                    $this->load($name, $subOption + $options);
                }
            }

            return $this;
        }

        //We are requesting primary loaded to pre-load nested relation
        $this->loader->loadRelation($relation, $options);

        return $this;
    }
public function load ( $ relation , array $ options = [ ] ) : self { if ( is_array ( $ relation ) ) { foreach ( $ relation as $ name => $ subOption ) { if ( is_string ( $ subOption ) ) { //Array of relation names $ this -> load ( $ subOption , $ options ) ; } else { //Multiple relations or relation with addition load options $ this -> load ( $ name , $ subOption + $ options ) ; } } return $ this ; } //We are requesting primary loaded to pre-load nested relation $ this -> loader -> loadRelation ( $ relation , $ options ) ; return $ this ; }
Request primary selector loader to pre-load relation name. Any type of loader can be used
for
data preloading. ORM loaders by default will select the most efficient way to load related
data which might include additional select query or left join. Loaded data will
automatically pre-populate record relations. You can specify nested relations using "."
separator.

Examples:

//Select users and load their comments (will cast 2 queries, HAS_MANY comments)
User::find()->with('comments');

//You can load chain of relations - select user and load their comments and post related to
//comment
User::find()->with('comments.post');

//We can also specify custom where conditions on data loading, let's load only public
comments. User::find()->load('comments', [
'where' => ['{@}.status' => 'public']
]);

Please note using "{@}" column name, this placeholder is required to prevent collisions and
it will be automatically replaced with valid table alias of pre-loaded comments table.

//In case where your loaded relation is MANY_TO_MANY you can also specify pivot table
conditions,
//let's pre-load all approved user tags, we can use same placeholder for pivot table alias
User::find()->load('tags', [
'wherePivot' => ['{@}.approved' => true]
]);

//In most of cases you don't need to worry about how data was loaded, using external query
or
//left join, however if you want to change such behaviour you can force load method to
INLOAD
User::find()->load('tags', [
'method'     => Loader::INLOAD,
'wherePivot' => ['{@}.approved' => true]
]);

Attention, you will not be able to correctly paginate in this case and only ORM loaders
support different loading types.

You can specify multiple loaders using array as first argument.

Example:
User::find()->load(['posts', 'comments', 'profile']);

Attention, consider disabling entity map if you want to use recursive loading (i.e.
post.tags.posts), but first think why you even need recursive relation loading.

@see with()

@param string|array $relation
@param array        $options

@return $this|RecordSelector
Request primary selector loader to pre - load relation name . Any type of loader can be used for data preloading . ORM loaders by default will select the most efficient way to load related data which might include additional select query or left join . Loaded data will automatically pre - populate record relations . You can specify nested relations using . separator .