CodeIgniter Forums
How to insert in OneToMany relationship - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: How to insert in OneToMany relationship (/thread-63159.html)



How to insert in OneToMany relationship - jeancarlos80s - 10-01-2015

How to is posible insert in relationship one to many.

table_movie
-id
-titulo

table_format
-id
-sigla

table_movie_format
-table_movie_id
-table_format_id


RE: How to insert in OneToMany relationship - freddy - 10-02-2015

Please tell us what you are trying to do, if you just give a schema table without detail explanation we can't help you !


RE: How to insert in OneToMany relationship - mwhitney - 10-05-2015

You have to insert the data in order to get the ID values required for the tables which manage the relationship(s) between the other tables. In other words, you would insert your data for table_movie and table_format, getting the id value for each after performing the insert, then you would insert those two id values into table_movie_format. If you insert multiple formats for a movie, you would insert the movie and get the id. Then insert a format, get the format's id, insert the two id values into table_movie_format, then repeat for each format (using the same movie id).