⚠ 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

set_relation the other way ?



takezo
  • profile picture
  • Member

Posted 12 May 2014 - 08:50 AM

Hello,

 

Here is my problem:

 

I have two tables :

  • PLACES
  • EQUIPEMENTS

 

PLACES

idplace (primary key)

name

address

 

EQUIPEMENTS

idequipement  (primary key)

name

idplace

 

As you see an EQUIPEMENT always have a PLACE (idplace). But there is some PLACES without equivalent EQUIPEMENT (places with no corresponding equipement).

My Goal is to have a CRUD for the PLACES table. But i would like to be able to visualize if the PLACE is in the EQUIPEMENT table or not (by having the idequipement or 0 if no corresponding equipement).

 

I would like a CRUD like this :

idplace | name       | idequipement

1          | myplace1 | 7

2          | myplace2 | 0

3          | myplace3 | 21

 

 

I know how i can do it the other way: having a CRUD for the EQUIPEMENT table and outputting an element of the PLACES table (using set_relation) but i want to do it for the other table.

 

I hope i'm clear...

 

Thank you!


ecaste
  • profile picture
  • Member

Posted 11 October 2014 - 14:14 PM

Hi,

did you find a way to do that ? I've exactly the same needs...

 

Thanks

Emmanuel


Amit Shah
  • profile picture
  • Member

Posted 12 October 2014 - 08:33 AM

Hello there

What you are asking is something not likely a set_relation job...

plus the single place can be connected to multiple equiopments

so what here the best option to go on with is -

1 - have a separate table place_equipments - and then u can have a set_relation_n_n

2 - add equipments as additional column to display instead of idequipment .. and have a callback_column for that where u retrieve related equipments and u can return a csv of equipments that u need to display

 

Hope this helps u out...

 

Happy GCing :)


ecaste
  • profile picture
  • Member

Posted 12 October 2014 - 09:02 AM

Hello there

What you are asking is something not likely a set_relation job...

plus the single place can be connected to multiple equiopments

so what here the best option to go on with is -

1 - have a separate table place_equipments - and then u can have a set_relation_n_n

2 - add equipments as additional column to display instead of idequipment .. and have a callback_column for that where u retrieve related equipments and u can return a csv of equipments that u need to display

 

Hope this helps u out...

 

Happy GCing :)

Hello,

thank you, you are right in some points and I'll do that, but what you propose may offer the possibility to have multiple places for 1 equipments, which is not true in his model. It's why a set_relation_1_n would have been preferable :)

Anyway, I'll do a set_relation_n_n

 

Thanks

Emmanuel

 

Emmanuel