简体   繁体   中英

cakePHP hasMany not joining the SQL query

I am unable to do a simple condition for my paginator. I have a Survey and Campaign models. Campaigns hasMany Surveys setup in the Campaign model.

I want to select a survey and the paginator should display the campaign is linked to, but I keep getting a Unknown column Survey.id - On inspection I see that Survey is not joined to the Campaign model, only in the WHERE clause. I also found out that hasMany does not join the tables to the query.

How else can I go about doing the above?

I could not find an answer to this. It appears that hasMany does not automatically get added to a query. I have had recommendations that using the containable feature in cake may help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM