Skip to content
Advertisement

ManyToMany relationship get the data

i am try to buid a ManyToMany relationship i have 3 Models movie,genres & moviegenres i want to get all genres for a movie for example $movie = Movie::find(); $movie->genres; i can put the genres in the same table but movies have more then 1 genre thus i would like the be able the filter if need be in the in the future i am using phalcon php as the framework

the genres Model

JavaScript

the movie model

JavaScript

and the moviegenres model

JavaScript

Advertisement

Answer

Your Movies class is where you want to put your many-to-many relationship, using MovieGenres as the intermediary.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement