There is something I do not get in your description. The way it's
described seems that a Customer has only one sub_tag. Since a Customer
record has subtag_id, but if you want to do this why create 2 models
is a Customer has only one subtag ? If this subtag is not shared among
Customer you could make a subtagcustomer model ..
Unless the model is wrong described, and a subtag can be shared by
many Customer, in such case you would need and HABTM relation ...
Also, you do not need to always make all relations, I mean for exemple
if you access your customer always by a tag/subtag, you do not need a
belongsto relation.
Maybe you need to refine your model, I do not know what the relation
you want beetween you different models.
On Mar 23, 8:56 pm, "d34db0lts" <[EMAIL PROTECTED]> wrote:
> hey guys, i have a question/problem regarding assocations. I have four
> tables:
>
> Tags
> id
> name
> description
>
> Subtags
> id
> name
> description
> tag_id
>
> Customers
> id
> name
> phone
> address
> subtag_id
>
> Descriptions
> id
> description
> customer_id
>
> these are my controllers:
> <?php
> class Tag extends AppModel
> {
> var $name = 'Tag';
> var $hasMany = array('Subtag' =>
> array( 'className' =>
> 'Subtag',
> 'conditions'
> => '',
> 'order'
> => '',
> 'limit'
> => '3',
> 'foreignKey'
> => 'tag_id',
> 'dependent'
> => true,
> 'exclusive'
> => false,
> 'finderQuery'
> => ''
> )
> );}
>
> ?>
>
> <?php
> class Subtag extends AppModel
> {
> var $name = 'Subtag';
>
> var $hasMany = array('Customer' =>
> array('className' => 'Customer',
> 'conditions' => '',
> 'order' => '',
> 'dependent' => true,
> 'foreignKey' =>
> 'subtag_id'
> )
> );
>
> var $belongsTo = array('Tag' =>
> array('className'
> => 'Tag',
>
> 'conditions' => '',
>
> 'order' => '',
>
> 'foreignKey' => 'subtag_id'
> )
> );
>
> }
>
> ?>
>
> <?php
> class Customer extends AppModel
> {
> var $name = 'Customer';
> var $hasMany = array('Description' =>
> array( 'className' =>
> 'Description',
> 'conditions'
> => '',
> 'order'
> => '',
> 'limit'
> => '',
> 'foreignKey'
> => 'customer_id',
> 'dependent'
> => true,
> 'exclusive'
> => false,
> 'finderQuery'
> => ''
> )
> );
>
> var $belongsTo = array('Subtag' =>
> array('className'
> => 'Subtag',
>
> 'conditions' => '',
>
> 'order' => '',
>
> 'foreignKey' => 'subtag_id'
> )
> );
>
> }
>
> ?>
>
> <?php
> class Description extends AppModel
> {
> var $name = 'Description';
>
> var $belongsTo = array('Customer' =>
> array('className' =>
> 'Customer',
> 'conditions'
> => '',
> 'order'
> => '',
> 'foreignKey'
> => 'customer_id'
> )
> );}
>
> ?>
>
> when a particular tag is clicked it shows a view that will display any
> subtags that tag might have and under each subtag it needs to display
> all the customers that have matching subtags and also display any
> descriptions associated with that customer.
>
> so far i can only make it show all subtags if the user clicked a
> particular tag...but i can't display all the customers associated with
> that subtag.
>
> thank you for any insight.
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---