dav
dav

Reputation: 9277

recursive -1 for all models cakephp

I want to set recursive -1 for all models, so I will not have to do it with every find request for each model.

I tried to do it from AppModel, like

function beforeFind($queryData) {
    $queryData['recursive'] = -1;
    return $queryData;
}

but it does not work, it gives an error, if I want to find some associative model with Containable - it can not find any field of the associated model - like

Column not found: 1054 Unknown column 'AssociatedModel.id' in 'field list'

Is there some way to handle this ? I use cake 2.3.1

Thanks

Upvotes: 1

Views: 933

Answers (1)

tigrang
tigrang

Reputation: 6767

In AppModel set public $recursive = -1; as a class var to set it for all models.

Upvotes: 4

Related Questions