I am doing some changes to a website running phpCake, where I am not totally familiar with. I tried their documentation, but unfortunately could not get a grasp on my problem.
I am trying to find an Item by id, with its children Videos, and with for each Video its child VideoThumbnail.
I have the following model configuration:
Item => hasMany Videos
Video => belongsTo Item
Video => hasOne VideoThumbnail
VideoThumbnail => belongsTo Video
I run the following code:
$this->Item->find('first', $options)
Is there something wrong in my configuration, or should I simply loop through the Videos and find the VideoThumbnails in the loop?
Thanks!
Use containable behavior
$options["contain"] = "Video.Videothumbnail";
$this->Item->find('first', $options)
Use the Containable behavior and use contain
option in find options to specify the associated records to fetch.
P. S. It's CakePHP not phpCake.