//方法1:
$query = User::find();
$name = [];
foreach($query->batch() as $users){
//$users 是一个包含100条或小于100条用户表数据的数组
foreach($users as $user){
$name[] = $user['username'];
}
}
return $name;
//方法2:
$query = User::find();
$name = [];
foreach($query->each() as $user){
// 数据从服务端中以 100 个为一组批量获取,
// 但是 $user 代表 user 表里的一行数据
$name[] = $user['username'];
}
return $name;