CakePHP 4.x Table::find('all', []) does not recognize 'contain' option

I have 2 queries as below, only the one with get($id, ‘content’ => []) works. The find(‘all’, ‘content’ => []) does only show ID instead of name of related content data.

    //get all campaign , and their related data
    $test = $this->Campaigns->find('all', ['contain' => ['Handlers','Creators']]);
    //set to view variable to see in debuger 
    $this->set('test', $test);
    //get only campaign id = 1, and it's related data
    $test1 = $this->Campaigns->get(1, ['contain' => ['Handlers','Creators']]);
    $this->set('test1', $test1);

Only $test1 include Handlers and Creators
while $test does not.

What should I do with this? I will put the $test into paginator as well.


$test = $this->Campaigns->find()->contain([‘Handlers’,‘Creators’]]);

1 Like

Thank you very much Salines,

I have tried the code you gave, it works.

So that mean CakePHP 4.0.1 has bug with Table querry, right?