[eluser]Chris Newton[/eluser]
I'm trying to build the results of a many-to-many relationship between 3 tables using the active record class. I maintain a news table containing all of the news item, a category table containing all of the category names & ids, and a join table, containing all of the news_ids & their respective category_ids.
I know how I could do this with standard PHP, but I'm trying to wrap my brain around the best way / best syntax for the active record class. I'm trying to build this many-to-many relationship without a lot of looping and I haven't come up with a working solution yet.
Table 1: ci_news
id,subject,content,date
Table 2: ci_news_to_categories
news_id
category_id
Table 3: ci_news_categories
id,name
Each news item may have multiple categories which is why I need the join table, rather than just adding category_id to the news table.
Does anyone have any working examples of a model that references this type of relationship?