Is there a reason you’re not simply using
contain to get the relevant Region entity included in the structure that you load, and then output it like
Hello Sir Zuluru,
Situation is: my experience with Cakephp framework is limited; As a volunteer of a Senior Citizen ONG using this application, I’m myself from a generation preceeding «Class» and MVC (82 years old now); I learned this php/MySQL using trial on error because of lack of possibilities of available training other than virtual; So in that activities.php controller, I do not know where to place or formulate that instruction in order to access that entity (etiquette) from region table, using ‘region_id’ from Regions table;
I learned so much consulting Cake Software Foundation Inc. website, thanks for all.
Feel free to guide me if possible to plug at proper place that «contain» Select so I can solve that problem;
If not, and possible, provide a contact in that field;
Thanks for that quick reply
The loading associations section of the manual describes how this works. In your case, it would be something like (possible this has typos in it, as I’ve had to re-type all of your code; providing it as text instead of graphics is a much more helper-friendly way to go in the future):
$inscriptions = $this->Activities->Inscriptions->find() ->contain(['Membres' => ['Regions']]) // or (['Membres.Regions']) but I prefer the flexibility of the former ->where([/* your conditions here */]);
Nice and concise.
Then, in your view, you would reference things like
$inscription->membre->region->etiquette. These are a little bit guesses, if your association from inscriptions to membres is
hasMany instead of
hasOne (you haven’t shown those), then it’ll be a bit different.
Note that if you use bake to generate your models and controllers and views, you’ll get code that does at least a bunch of this for you. Probably not in exactly the form you want, but it generally provides an excellent starting point to work from, including one level of containment so it’s clear how to access things.