我必须将数组传递给分页。那么如何将数组转换为对象ORM以设置为分页?
我不能$ this-> paginate = [];因为我必须应用一些foreach和条件,所以我才首先找到所有的东西。
$allProductData = $this->PurchaseRequisitionProducts->find('all',[
'contain' => ['PurchaseRequisition','PurchaseOrderProducts'=>function($c){
if($c==null){ return null; }
return $c->where(['PurchaseOrderProducts.id IS NOT NULL']);
},'PurchaseOrderProducts.PurchaseOrder'=>function($p){
return $p->where(['PurchaseOrder.id IS NOT NULL'])
->where(['PurchaseOrder.is_approve'=>"Y"])
//->where(['PurchaseOrder.status'=>1])
->where(['PurchaseOrder.po_type'=>1]);
},'PurchaseOrderProducts.PurchaseOrder.CompanyMaster'] ,
'conditions'=>[$condn,$conditions,'PurchaseRequisition.ready_for_inquiry'=>'Y','PurchaseRequisition.owner_company_id'=>$ownercomp],
'order'=>["PurchaseRequisitionProducts.id"=>"desc"],
])->toArray();
if($allProductData){
foreach($allProductData as $key1=>$prProd){
if(isset($prProd['purchase_order_products'])){
$supplier=[];
foreach($prProd['purchase_order_products'] as $key2=>$poProd){
$supplier[]=$poProd['purchase_order']['supplier_id'];
//debug($supplier);
$companies= $this->CompanyMaster->find('list', [
'keyField' => 'id','valueField' => 'Company_name',
'conditions'=>['id IN'=>$supplier],
])->toArray();
$allProductData[$key1]['supplier']=$companies;
}
}
}
}
$pr_product = $this->paginate($allProductData)