⚠ 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

Relation n-n and fields concatenation



ALM
  • profile picture
  • Member

Posted 26 September 2012 - 08:31 AM

[color=#2C575B][font=Arial, Tahoma, Helvetica, sans-serif]I want to set a relation with n-n relationship like the example posted here[/font][/color]
[font=Arial, Tahoma, Helvetica, sans-serif][color=#2c575b]But instead of the actor's fullname, i have two fields : name and surname[/color][/font]

[color=#0000FF][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]$crud[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]->[/size][/font][/color][color=#006600][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]set_relation_n_n[/size][/font][/color][color=#66CC66][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]([/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'actors'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3], [/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'film_actor'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3], [/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'actor'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3], [/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'film_id'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3], [/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'actor_id'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3], [/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'name'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3],[/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'priority'[/size][/font][/color][color=#66CC66][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3])[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3];[/size][/font][/color]
I have only the name

[color=#0000FF][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]$crud[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]->[/size][/font][/color][color=#006600][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]set_relation_n_n[/size][/font][/color][color=#66CC66][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]([/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'actors'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3], [/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'film_actor'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3], [/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'actor'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3], [/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'film_id'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3], [/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'actor_id'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3], [/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'surname'[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3],[/size][/font][/color][color=#FF0000][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3]'priority'[/size][/font][/color][color=#66CC66][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3])[/size][/font][/color][color=#333333][font=Menlo, Monaco, Consolas, 'Courier New', monospace][size=3];[/size][/font][/color]

I have only the surname

[font=Arial, Tahoma, Helvetica, sans-serif][color=#2c575b]I wanted to concat them in order to have the fullname with the relation[/color][/font]

[color=#2C575B][font=Arial, Tahoma, Helvetica, sans-serif]Is there an easy way to do that ?[/font][/color]

saulimus
  • profile picture
  • Member

Posted 26 September 2012 - 09:46 AM

You can do it like this:
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', '{name} {surname}','priority');

ALM
  • profile picture
  • Member

Posted 27 September 2012 - 14:55 PM

simply ans so easy ! thank you very much for your answer