当前位置: 首页>>代码示例>>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;未经允许,请勿转载。