Is there any way to access other fields in join tables. For example I have a books model and an authors model with a join table matching the book_ISBN to the author_id and I also have an order column in the join table which ranks the authors if there are multiple authors for a single book.
Heres a reference table example. You can see that there are 2 entries for the same book with 2 authors. one of the authors is ranked with a 1 in the order column denoting that they are the primary author for listing.
Unsure if this can be accessed through setting something in the ‘fields’ option for the author model in the has_many_and_belongs_to array.
book_ISBN | author_id | order
1234 | 1 | 1
1234 | 2 | 2
5678 | 3 | 1
Will I need to do a second query directly on that table to get that columns data and then append it into the $this->object variable in the after_find() method?
- The topic ‘[Plugin: WP MVC] Accessing fields other than foreign_keys in Join Tables’ is closed to new replies.