0

I need join and virtual field with the pagination in index.ctp. I wrote same code that is working cakephp 2.x but in cakephp 3.5 this below code is not working. when I am taking 'pdt' to under contain it's show error TestRequest is not associated with pdt and when I am taking separate field then also getting error Unknown column 'TestRequest.pdt' in 'field list'

Where i need correction on below code?

public function index()
{
    $this->paginate = [
        'contain' => ['OwnerCompanies', 'ProductsMaster','TestRequestDet'],
        //'fields' => ['pdt'],
        'joins' => [                    
                [                       
                     'table' => 'product_data_tests',
                     'alias' => 'pdt',
                     'conditions'=> array('TestRequestDet.test_id = pdt.id'),
                     'type' => 'left'   
                ]
    ] ];       

    $this->TestRequest->virtualFields = [
            'test_name'=>'pdt.test',
            'specification'=>'pdt.specification',
            'method'=>'pdt.methods',
    ];
    $testRequest = $this->paginate($this->TestRequest);

    $this->set(compact('testRequest'));
    $this->set('_serialize', ['testRequest']);
}
SamHecquet
  • 1,818
  • 4
  • 19
  • 26
  • 1
    Can you tell us what kind of association is used for `TestRequestDet` because it has to be a joinable type if you're going to use it in another join. – Reactgular Jan 04 '18 at 02:21
  • TestRequest hasMany TestRequestDet so multiple TestRequestDet data is storing into the TestRequestDet table and with that TestRequestDet id I have to find all product_data_tests – Devendra Vastrakar Jan 04 '18 at 06:06

0 Answers0