⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

two relation_n_n not work



vnt

vnt
  • profile picture
  • Member

Posted 22 February 2012 - 14:15 PM

I have put two relation_n_n in the form, why are saved only data of a relation_n_n?

1) $crud->set_relation_n_n('strutture', 'vnt_relazioni', 'vnt_strutture', 'idMultimedia', 'idStruttura', 'ramo');
2) $crud->set_relation_n_n('contenuti', 'vnt_relazioni', 'vnt_contenuti', 'idMultimedia', 'idContenuto', 'titolo','posizione');

only the second relations is saved.

if you comment a set_relation_n_n, the other is properly saved.

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 22 February 2012 - 23:34 PM

Yes this is because the [color=#282828][font=helvetica, arial, sans-serif]vnt_relazioni is the same. In general it works with two or more set_relation_n_n but it never happens to have the middle table the same name. I don't want to make my code more complicated for this scenario, are you sure that your database structure is right? For me as I see it you must have two different tables so it will be:[/font][/color]

[color=#282828][font=helvetica, arial, sans-serif]

$crud->set_relation_n_n('strutture', 'vnt_relazioni', 'vnt_strutture', 'idMultimedia', 'idStruttura', 'ramo');
$crud->set_relation_n_n('contenuti', 'vnt_relazioni2', 'vnt_contenuti', 'idMultimedia', 'idContenuto', 'titolo','posizione');
[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]I log this as an issue ( [/font][/color]https://github.com/scoumbourdis/grocery-crud/issues/11[color=#282828][font=helvetica, arial, sans-serif] ) to fix it when I will have time. [/font][/color]