It's hard to tell without knowing more about what you're trying to do or seeing your Course model, but you're presumably receiving that error because CourseCategoryID does not exist on the "Course" table - where() is called in the context of Course::get() in your example code. Simply creating a Course model and a Category model would be sufficient to set up a relation table without resorting to innerJoin, which would have a schema resembling this:
(id, localKey, foreignKey)
id | course_id | category_id
source: inferred from http://api.silverstripe.org/master/source-class-ManyManyList.html#107
Is this a table that was created within the framework or some legacy code that was generated elsewhere? You can write straight SQL using the DB::query() function
Posted to: Many-to-many Unknown column | Show Thread | Post Reply