Jump to content
Larry Ullman's Book Forums

Multiple Departments


hesedwebdev
 Share

Recommended Posts

Hello,

 

I am working through the tutorial for Yii on the website, and I have setup the Employee and Department models. However, this only addresses if an Employee has 1 department. What would I need to do if I wanted to be able to list multiple departments under the column 'departmentId' separated by commas or pipes, etc?

Link to comment
Share on other sites

I guess I should shed more light. I know I would need something in the models to take the field under departmentId and evaluate if it has the chosen separator (for sake of the example, I will say the separator is ',' [*comma*]) and then break that into an array. Then the relations should run through the array and get all the departments that match those IDs. But since I am obviously new to Yii, I do not know if:

  • A. How or what needs to be edited, OR
  • B. If there is an easier or better way to do this.

I have thought about making an employeesDepts table that has individual entries of every departmentId for an employeeId, but then again incorporating this is my difficulty.

 

Any help is greatly appreciated.

Link to comment
Share on other sites

 Share

×
×
  • Create New...