We have 3 tables
1. cms_articles (id, title) - CMS articles
2. shop_categories (id,title) - Categories
3. shop_categories_cms_article (cms_article_id, shop_category_id)
(Articles for a specific category)
Data set:
1. cms_articles (1, 'Article no 1')
2. shop_categories (1, 'Vibrators')
3. shop_categories_cms_articles(1,1) - meaning the category Vibrators
has one article -> Article no. 1
We have the model:
class CmsArticle extends AppModel
{
var $name = 'CmsArticle';
var $hasAndBelongsToMany = array(
'ShopCategory' =>
array('className' => 'ShopCategory',
'conditions' => '',
'order' => '',
'foreignKey' => '',
'joinTable' =>
'ShopCategoriesCmsArticle',
'associationForeignKey' => '',
'uniq' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''),
}
And we have the controller
class ShopController extends AppController {
var $name ='CmsArticle';
function index() {
$test_var = $this->CmsArticle->findbyid(1);
$this->set('test_var',$test_var);
}
}
Output
Array
(
[CmsArticle] => Array
(
[id] => 1
[title] => Article no. 1
)
[ShopCategory] => Array
(
)
)
Why don't I get all the information from CmsArticle ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---