from(Ghs::tableName()); $query->where(['mobile' => '']); foreach ($query->batch(10) as $batch) { foreach ($batch as $ghs) { $ghsId = $ghs['id']; $shopId = $ghs['shopId']; $shop = ShopClass::getByCondition(['id' => $shopId], true, null, 'id,mobile'); if (!empty($shop)) { $mobile = $shop->mobile; if (!empty($mobile)) { GhsClass::updateById($ghsId, ['mobile' => $mobile]); echo $mobile . "\n"; } } } } } }