JaquelineBrandao / yii

Automatically exported from code.google.com/p/yii
0 stars 0 forks source link

Save / Edit / Delete for MANY_MANY #689

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice if there was more support for MANY_MANY relation.. insert
/ update, delete is missing.

Original issue reported on code.google.com by chris.de...@gmail.com on 25 Nov 2009 at 12:02

GoogleCodeExporter commented 9 years ago

Original comment by qiang.xue on 7 Dec 2009 at 12:17

GoogleCodeExporter commented 9 years ago
i think it would be a great improvement to have many-many support in crud
command...please yii guys take a look at this feature carefully..

:>))

Original comment by scoob.ju...@gmail.com on 12 Feb 2010 at 12:28

GoogleCodeExporter commented 9 years ago
Not only CRUD... the ORM should support it.

Original comment by chris.de...@gmail.com on 12 Feb 2010 at 12:31

GoogleCodeExporter commented 9 years ago
you could take a look at CAdvancedArBehavior - it has a somewhat better 
MANY_MANY
support for Active Record Models and is implemented as a behavior now.

http://www.yiiframework.com/extension/cadvancedarbehavior/

Original comment by Ingo.Gro...@googlemail.com on 5 Mar 2010 at 3:21

GoogleCodeExporter commented 9 years ago
it's a good extension, but something would still be missing in my opinion:

CRUD tables with composite primary keys

also, I think that these kind of features would be better supported if they 
were in
the Yii core/crud core instead of extensions

but thanks anyway for the tip :)

Original comment by scoob.ju...@gmail.com on 5 Mar 2010 at 4:32

GoogleCodeExporter commented 9 years ago
ps.  I know Qiang has said that Yii team wants to keep the code generated by 
crud
simple, but think guys, in a real world application we usually have lots of 
tables
with composite primary key and not implementing this feature in CRUD because of 
the
"simplicity" just lead developers to waste a lot of time by creating all thinks
manually...CRUD is one of the most important features that made me start using 
Yii
and imho many other developers think this way (if we have doubts we could open a
topic in the forum and wait for votes)

I think that Yii is one of the best frameworks, but it would become almost 
perfect if
composite keys were supported in CRUD. This feature would be a huge advantage in
using Yii and Yii's crud would be 100% useful, meaning suitable for all sort of
tables and relations (with this many-many improvement)

well, these are my little thoughts about CRUD at the moment...hope that one day 
Yii
team could change their mind about this "tool"

:-)

regards!!!

Original comment by scoob.ju...@gmail.com on 5 Mar 2010 at 4:53

GoogleCodeExporter commented 9 years ago
I think maybe we are spoiled as most of the other Frameworks have support for 
it 
already ^^ wishing for v 1.2 ? :P

Original comment by chris.de...@gmail.com on 5 Mar 2010 at 4:56

GoogleCodeExporter commented 9 years ago
I agree with Scoob.Junior about needed CRUD capabilities on composite primary 
keys. 
The whole point of scaffolding is to quickly get going on 'regular' tasks and 
its a
shame that this feature overlooks composite primary keys.  Sometimes developers 
have
to work on existing databases where the schema cannot be changed and not having 
this
feature defeats the scaffolding purpose.

Original comment by Blit...@gmail.com on 3 Jun 2010 at 5:13

GoogleCodeExporter commented 9 years ago
On the topic of composite keys --

Someone somewhere has probably already thought of this, but just in case, it 
would be great to see an additional form generated that contain the parent 
record with an active record listing subordinate records. 

Allot of applications have been developed like this, some RAD apps will create 
these form types. 

This framework is an absolute outstanding work. Having worked with early OO 
client server apps, pre-web in the 1980s and early 90s, including some with 
asynchronous features that communicated between multiple platforms, I know 
something of what I speak. 

With that said, all good works tend to stay alive in development, continually 
improving and therefore offering quality in form and function. We have two 
choices; 1) either sit and wait or, 2) offer some suggestions. I will engage in 
the later as soon as I gain a bit more confidence with these tools. Until then, 
the more experienced folks need to examine the possibilities in order to find 
the most appropriate path to a solution. 

cheers!

Original comment by ChuckF...@gmail.com on 10 Jun 2010 at 7:56

GoogleCodeExporter commented 9 years ago
I may suggest to take a look at this behavior I did:
http://www.yiiframework.com/extension/save-relations-ar-behavior/
As a former CakePHP developer, It was something which I missed and I think this 
extension is covering most of the expected functionalities to manage relations 
handeling.

Original comment by alban.ju...@trinidev.fr on 10 Jun 2010 at 8:36

GoogleCodeExporter commented 9 years ago
CRUD tables with composite primary keys, Would be great. :)

Original comment by inluxc on 29 Sep 2010 at 10:02

GoogleCodeExporter commented 9 years ago
ya, crud tables with composite primary key... :)) will be very great !! miss it 
!

Original comment by jimmi.na...@gmail.com on 31 Mar 2011 at 9:10

GoogleCodeExporter commented 9 years ago
Deleting a many many needs to have the ability to specify which relations need 
to be removed rather than simply all.

Currently with CAdvancedArBehavior, when saving, it first deletes all entries 
and then adds the new ones.

With a native solution, it would be nice if it were possible to have an option 
to simply add new ones without deleting, or when editing, to deleting the old 
value and adding the new one leaving the rest intact.  There's need to be 
options for ->delete() or something like ->deleteRelation()

Also, when creating a new model it would be cool to have something like is 
mentioned here:
http://www.yiiframework.com/forum/index.php?/topic/17605-eager-creation-of-model
s-and-more-chtmlresolvename-relational-support/

Original comment by pha...@gmail.com on 1 Apr 2011 at 8:46

GoogleCodeExporter commented 9 years ago
Hope to see this improvement too!

Original comment by slin...@gmail.com on 11 Apr 2011 at 10:56

GoogleCodeExporter commented 9 years ago
Here is my try to add MANY_MANY support into AR:
  http://www.yiiframework.com/extension/advancedrelationsbehavior/

without SQL queries generation, just AR features was used, composite primary 
key support also can be added, but I try to keep my code clean

Original comment by a.jil...@gmail.com on 12 May 2011 at 1:01

GoogleCodeExporter commented 9 years ago
Checkout my ESaveRelatedBehavior 

Features:
- handles many_many and has_many relations
- fills has_many relations with validated objects
- processes everything within a transaction
- relations can be set with data arrays or object arrays
- only specified relations are saved
- massive assignment works, since data is set on relation directly
- adds 2 methods to activeRecord, no use of beforeSave/afterSave,
therefore the behavior can be added to all activeRecord classes,
it will only do its work when the new methods are called
- uses standard SQL
- NO HANDLING OF COMPOSITE KEYS yet

Original comment by sluderitz@gmail.com on 22 Jun 2011 at 12:19

GoogleCodeExporter commented 9 years ago
Composite keys are a proper database principle. They primarily indicate that a 
record exists because it's parents records exist. If the parents don't exist 
then the child cannot exist. Makes sense. Although the Yii team explanation of 
not complicating generated code also makes sense.

Original comment by kieran.k...@gmail.com on 5 Jul 2011 at 4:33

GoogleCodeExporter commented 9 years ago
CRUD with composite key support playing important role!.

Regards,

Original comment by corozon....@gmail.com on 28 Aug 2011 at 8:28

GoogleCodeExporter commented 9 years ago
We have a prototype in form of behavior for 1.1: 
https://github.com/yiiext/with-related-behavior Well-tested, expect English 
docs this week.

Original comment by alexander.makarow on 26 Sep 2011 at 8:19

GoogleCodeExporter commented 9 years ago
Awesome, that's excellent news Alexander!

Original comment by intel352 on 26 Sep 2011 at 8:59

GoogleCodeExporter commented 9 years ago
Looking forward to it Alexander, Thanks !

Original comment by kossaw....@gmail.com on 2 Oct 2011 at 4:44

GoogleCodeExporter commented 9 years ago
Added English docs. Please provide feedback to this extension's repository. 
Hopefully we'll come to a good API / workflow as it goes.

Original comment by alexander.makarow on 6 Oct 2011 at 11:12

GoogleCodeExporter commented 9 years ago
This behavior is useless, its works only with new records
when related is:
$tr = new TrainingsTraining();
$tr->name = 'a';
$tr->name_cert = 'b';
$tr->description = 'c';
$model->trainings = array($tr);

it works, but in real world related records are already in db

but 

when related are 

$model->trainings = 
TrainingsTraining::model()->findAllByPk($model->training_ids);

its not saving ralations.

Original comment by dariusz....@gmail.com on 26 Oct 2011 at 9:26

GoogleCodeExporter commented 9 years ago
This works with new records and when records is already in db. If you have 
problem with this behavior, please post issue 
https://github.com/yiiext/with-related-behavior/issues. No need write here.

Original comment by creocoder@gmail.com on 26 Oct 2011 at 2:11

GoogleCodeExporter commented 9 years ago
Migrated to http://github.com/yiisoft/yii/issues/297

Original comment by qiang.xue on 15 Feb 2012 at 6:48

GoogleCodeExporter commented 9 years ago
Please add support for gii crud creation for composite primary key

Original comment by khan...@gmail.com on 17 Nov 2012 at 8:19

GoogleCodeExporter commented 9 years ago
composite key support is really a key feature here +vote for me ....

Original comment by ian.j.ta...@gmail.com on 26 Jul 2013 at 2:57