Limit contained record - not working!

That’s due to how the ORM works, associated data is either retrieved in a separate query (hasMany/belongsToMany), or in a join (hasOne/belongsTo, this can also be changed to use a separate query). For the former if you apply a limit, it will limit the overall number of associated records, not the records “per parent”.

You could give icings/partitionable a try. Also check cakephp - How to limit contained associations per record/group? - Stack Overflow for some additional workarounds.

1 Like