db icon indicating copy to clipboard operation
db copied to clipboard

Add `ArrangeBy` option

Open Tigrov opened this issue 1 year ago • 1 comments

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,        
    ],
];

Tigrov avatar Jun 05 '24 10:06 Tigrov

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

vjik avatar Jun 07 '24 07:06 vjik