Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ArrangeBy option #360

Open
Tigrov opened this issue Jun 5, 2024 · 1 comment
Open

Add ArrangeBy option #360

Tigrov opened this issue Jun 5, 2024 · 1 comment
Labels
type:enhancement Enhancement

Comments

@Tigrov
Copy link
Member

Tigrov commented Jun 5, 2024

Similar to IndexBy, this option will arrange records by a value.

For example

$userQuery = new ActiveQuery(User::class, $db);

$users = $userQuery->arrangeBy('status')->all();

The result is

[
    'active' => [
        0 => User,
        1 => User,
        2 => User,
    ],
    'inactive' => [
        0 => User,
        1 => User,        
    ],
];
@samdark samdark added the type:enhancement Enhancement label Jun 5, 2024
@vjik
Copy link
Member

vjik commented Jun 7, 2024

It's also will be userfull in Query from Yii DB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants