How to access multiple tables in a single file


My problem it’s very simple but I can’t use any model other than the model associated with my controller.

I have plants, they are in a greenhouse. I would like to display the plants according to the greenhouse each time but I cannot call the plants in my controller (greenhouse).

Please, how to make this? :’(


Assuming that the tables are associated, you could use something like $this->Greenhouses->Plants. Or load an additional model. Or use the TableRegistry. Or consider that perhaps if your goal is to display plants, that function should actually be in the Plants controller, not the Greenhouses one.

Sorry, i don’ understand.

I will explain my problem.
I have my greenhouse contoller, I have my plant controller and I would like to display the plants corresponding to the greenhouse after clicking on the greenhouse. But I don’t know how to set this up. CakePhP is my first framework and must say that I am having a lot of trouble.

This is Greenhouse table


This is plants table :


Please, help me…

Have you gone through the tutorial? This seems very much like the relations that it takes you through. Also, have you used the bake command? That should generate much of this code for you, though it seems that your naming scheme may not be standard (e.g. I don’t know if bake works with upper case letters in column names; it very well may, but most everyone that uses Cake uses all lower case column and table names), so that might hinder it somewhat.

Ok thank you soo much!!