douhuxi4145 2018-10-25 07:02
浏览 22

如何在我的php文件中使用详细的标志和摘要获取此输出?

So I have a problem where I need to get this output with verbose flag:

20181022 10:00:02 - org_added/id:1234

20181022 10:00:02 - org_updated/id:1235

20181022 10:00:02 - user_added/id:1235

20181022 10:00:02 - org_updated/id:1235

And this output with a summary:

added orgs: 120

updated orgs: 2220

added users:2

updated users: 3300

And here is my code:

foreach ($organizations as $organization) {
            try {
                if ($zenOrgs = $this->client->organizations()->search($organization['external_id'])) {
                    $this->client->organizations()->update($zenOrgs->organizations[0]->id, $organization);
                }
            } catch (\Exception $exception) {
                try {
                    $this->client->organizations()->create($organization);
                } catch (\Exception $exception) {
                    \Cli::error($exception->getMessage());
                }
            }
        }
        foreach ($users as $user) {
            try {
                if ($zenUsers = $this->client->users()->search(['external_id' => $user['external_id']])) {
                    $this->client->users()->update($zenUsers->users[0]->id, $user);
                }
            } catch (\Exception $exception) {
                var_dump($exception->getMessage());die;
                try {
                    $this->client->users()->create($user);
                } catch (\Exception $exception) {
                    \Cli::error($exception->getMessage());
                }
            }
        } 

But I just can't figure out how to implement these two things so that I can get that output. Could anybody help me with this?

Thanks a lot!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化