How to the data available in a 4th column in cakephp?
Currently i'm having a problem. I want t开发者_JAVA技巧o access the data available in the 4th table of my DB.
Db image:
I have the tables in this way: Categories --> Categories_Companies --> Companies --> Affiliates
Like it shows in the image i'm on the categories and in the Categories view (views/categories/view.ctp) i want to show the fields title and url from the affiliates table.
There is another way of doing that without using the this->query?
Regards
You access a table through its model. The Category model is automatically included in the CategoriesController by naming convention. You can include other models by using $uses
.
var $uses = array('Category', 'Affiliate');
function view() {
$this->Category->find(…);
$this->Affiliate->find(…);
}
Or, if your models are linked through associations, you can access them through an association:
$this->Category->Company->Affiliate->find(…);
Both examples are equivalent, the first is just more convenient.
精彩评论