Open Tigrov opened 3 months ago
Similar to IndexBy, this option will arrange records by a value.
IndexBy
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, ], ];
It's also will be userfull in Query from Yii DB.
Query
Similar to
IndexBy
, this option will arrange records by a value.For example
The result is