Pagination not working in a cakephp 3 union

2019-08-25 07:39发布

问题:

Pagination not working when trying to do a union in cakephp 3

                $tenant = $this->Tenants->find('all', [
                    'fields' => ['Tenants.id','Tenants.created','Consumers.type'],'conditions'=>['Tenants.clientid' => '1'],'order' => 'Tenants.created desc'])->contain(['Consumers'])
                    ;

                $buyer = $this->Buyers->find('all', [
                    'fields' => ['Buyers.id','Buyers.created','Consumers.type'],'conditions'=>['Buyers.clientid' => '1'],'order' => 'Buyers.created desc'])->contain(['Consumers'])
                    ;

                $results = $buyer->unionAll($tenant);

                $results = $results->epilog(
                    $con->newQuery()->order(['created' => 'DESC'])
                );
                $results=$this->paginate($results);