Yii Framework Forum: Which extension for Many_many save related ? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Which extension for Many_many save related ? Rate Topic: -----

#1 User is offline   wyginwys 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 15-February 12

Posted 06 June 2012 - 08:54 AM

Hi
I have setup a MANY_MANY relation at last and now I need to save the related model.
I see there are some extensions (save-relations-ar-behavior, esaverelatedbehavior etc)
which does this job. I want to use a more recent one.

Could you recommend one for me?
0

#2 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,269
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 06 June 2012 - 08:56 AM

I can wholeheartly recommend the with-related-behavior :D
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
0

#3 User is offline   wyginwys 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 15-February 12

Posted 07 June 2012 - 07:52 AM

View PostDa:Sourcerer, on 06 June 2012 - 08:56 AM, said:

I can wholeheartly recommend the with-related-behavior :D


Thanks for pointing out the extension and the site which I wasnt aware of.
I am trying to save a Post with Categories using table tbl_post_categories as described in the definitive guide.
In tbl_post_categories I have two primary keys, postid,categoryid which are also foreign keys referencing Post and Category
tables.
I have MANY_MANY relations defined in both models Post, Category against each other and also
I have HAS_MANY relations pointing to tbl_post_categories table in both.
and I have BELONGS_TO relations in tbl_post_categories pointing Post and Category tables.

How should I use WithRelatedBehaviour in this case?
I am getting
Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
errors on my tries.
The error is straightforward because there is no corresponding key in the referencing table.
But How can I save a tbl_post_category model without knowing its postid?
0

#4 User is offline   hastenax 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 27-February 12

Posted 20 July 2012 - 07:31 AM

View Postwyginwys, on 06 June 2012 - 08:54 AM, said:

Hi
I have setup a MANY_MANY relation at last and now I need to save the related model.
I see there are some extensions (save-relations-ar-behavior, esaverelatedbehavior etc)
which does this job. I want to use a more recent one.

Could you recommend one for me?


You can also try github.com/hastenax/yii-cmanymanyactiverecord without any db constraints.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users