Wednesday, April 28, 2010

Problem with HABTM Assocation

Hello Frnds,
I have 2 models like 'Deal' and 'Attribute'. I created HABTM
relationship with these model. In my deal model class l wrote
var $hasAndBelongsToMany = array(
'Attribute' => array(
'className' => 'Attribute',
'joinTable' => 'attributes_deals',
'foreignKey' => 'deal_id',
'associationForeignKey' => 'attribute_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
),

And in my Attribute Model class I worte

var $hasAndBelongsToMany = array(
'Deal' => array(
'className' => 'Deal',
'joinTable' => 'attributes_deals',
'foreignKey' => 'attribute_id',
'associationForeignKey' => 'deal_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
),

And after this when i save deal then my cross table 'attributes_deals'
working fine. but not save the record of extra field of
`attributes_deals` table. So can anyone tell me how its possible.
Dump of of my table:---------

CREATE TABLE `attributes_deals` (
`id` int(11) NOT NULL auto_increment,
`deal_id` int(11) NOT NULL,
`attribute_id` int(11) NOT NULL,
`value` varchar(100) NOT NULL,
`created` datetime NOT NULL,
`modified` datetime NOT NULL,
PRIMARY KEY (`id`)
) ;
I want to store attribute value in my value field of this table with
HABTM. So can any one tell me how it is possible.

Thanks...

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: