當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::chunk方法代碼示例

本文整理匯總了PHP中RainLab\User\Models\User::chunk方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::chunk方法的具體用法?PHP User::chunk怎麽用?PHP User::chunk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RainLab\User\Models\User的用法示例。


在下文中一共展示了User::chunk方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: up

 /** 
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     User::chunk(500, function ($users) {
         foreach ($users as $user) {
             if (strlen($user->barcode_id) > 10) {
                 $user->barcode_id = substr($user->barcode_id, 0, 9);
                 $user->forceSave();
             }
         }
     });
 }
開發者ID:janusnic,項目名稱:OctoberFriends,代碼行數:16,代碼來源:fix_barcodes.php

示例2: updateExistingUsers

 /**
  * Updates the metadata from wordpress on existing users
  */
 public function updateExistingUsers()
 {
     OctoberUser::chunk(500, function ($users) {
         foreach ($users as $user) {
             $id = $this->db->table('wp_users')->select('ID')->where('user_email', $user->email)->first();
             if (!$id) {
                 continue;
             }
             $this->updateMetadata($user, $id->ID);
         }
     });
 }
開發者ID:janusnic,項目名稱:OctoberFriends,代碼行數:15,代碼來源:User.php

示例3: synchronizeUser

 protected function synchronizeUser()
 {
     $alwaysUpdate = $this->option('force-update');
     $this->progressbar = $this->getHelperSet()->get('progress');
     $this->progressbar->start($this->output, User::count());
     User::chunk(500, function ($users) use($alwaysUpdate) {
         foreach ($users as $user) {
             $this->progressbar->advance();
             $email = $user->email;
             MailChimpIntegration::syncMemberToMailChimp($email, $user, false);
         }
     });
     ${$this}->progressbar->finish();
 }
開發者ID:janusnic,項目名稱:OctoberFriends,代碼行數:14,代碼來源:SyncFriendsToMailChimp.php

示例4: fire

 /**
  * Read and process incomming data from listenable channels
  * @return void
  */
 public function fire()
 {
     // Long run queries fill memory pretty quickly due to a default
     // behavior of Laravel where all queries are log in memory. Disabling
     // this log fix the issue. See http://laravel.com/docs/4.2/database#query-logging
     DB::connection()->disableQueryLog();
     User::chunk(200, function ($users) {
         foreach ($users as $user) {
             $this->increaseCounter('total_users');
             $data = $this->normalize($user);
             foreach ($data as $attr => $value) {
                 $user->{$attr} = $value;
             }
             $user->forceSave();
         }
     });
     var_dump($this->counters);
     var_dump($this->writeReport());
 }
開發者ID:janusnic,項目名稱:OctoberFriends,代碼行數:23,代碼來源:NormalizeUserData.php


注:本文中的RainLab\User\Models\User::chunk方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。