column('path', 'id'); $count = Db::name('customer')->whereOr($condition)->count(); $page = ceil($count / 1000); for ($p = 1; $p <= $page; $p++) { $data = Db::name('customer')->whereOr($condition)->page($p, 1000)->select(); foreach ($data as $item) { $path = $org[$item['org_id']]; $a = explode('-', $path); $root_id = array_shift($a); if ($item['designer_id'] != null) { $saveData = [ 'customer_id' => $item['id'], 'employee_id' => $item['designer_id'], 'root_id' => $root_id, 'addtime' => time() ]; try { Db::name('customer_sharing')->insert($saveData); } catch (PDOException $e) { print_r($e->getMessage()); } } else { $l = explode(',', $item['assigned_personnel']); foreach ($l as $i) { $saveData = [ 'customer_id' => $item['id'], 'employee_id' => $i, 'root_id' => $root_id, 'addtime' => time() ]; try { Db::name('customer_sharing')->insert($saveData); } catch (PDOException $e) { print_r($e->getMessage()); } } } } } } }