如何在 CakePHP 中取消设置数组对象的对象

问题描述 投票:0回答:0

我有这个问题:

$clients = $this->Users->find('all') ->contain(['Sale', 'Sale.Areas', 'Transactions' => function ($q) { return $q->where(['kind = ' => 'QUOTA']) ->select(['Transactions.user_id', 'Transactions.status', 'Transactions.payout_date']); },'Sale.Areas.Projects', 'UserLogs' => function ($q) { return $q->select(['created', 'user_id', 'grade'])->order(['created DESC']); } ]) ->where(['posventa_consultant_id =' => $uid]) ->where(['Sale.status =' => 'aproved']);

我打印查询答案的类型 dd(gettype($clients));我明白了:“对象”enter image description here enter image description here

我想删除有非活动项目执行此过滤器的客户:

foreach ($clients as $key => $client) { if($client->sale[0]->area->project->active == 0){ unset($clients[$key]); }

我终于收到这个错误信息:

不能使用 Cake\ORM\Query 类型的对象作为数组enter image description here

我想删除我的查询响应的任何对象。

php mysql arrays object cakephp-3.0
© www.soinside.com 2019 - 2024. All rights reserved.