Welcome Guest, Not a member yet? Register   Sign In
Junction tables place in CI MVC arhitecture

This is my first post so I would first like to say hey to the good community of CodeIgniter!

I have a question regarding model/controller design and some other stuff I don't understand completely.

I followed some tutorials, did some experimenting and finally decided to finish a project using CI. I have also been learning MySQL and OO PHP. Along the way I've shaken hands with Bootstrap (grid system, modals), JQuery plugins (multiselector, tinymce, datepicker) and server administration (I've made my own using RaspberryPi). This information is just to shed some light on the level of my experience (beginner to novice) Smile

So the project is actually a CMS of sorts to help out a local youth organization present themselves on the web. Right now I'm finishing the backend admin panel for adding content and some things didn't quite add up.

I have four tables and a junction table like so:
TeamsTo Seasons

There are 18 seasons so far and around 200 teams through out the organization history. I created a "edit"/"add new" view for each of the basic tables (Posts, Teams and Seasons) represented as a form. So there is many-to-many relationship between Seasons and Teams and the TeamsToSeasons junction table represents this relationship.

This is where the confusion kicks in. I've been using one core Model and two core Controllers (frontend/backend) as parents. My core model has all the basic CRUD functionality that worked perfectly with Posts and Teams tables, but I had to override all that functions for my Seasons model. Seasons model also takes TeamsToSeasons table as a field and I did not create a new model for junction table, but I already see some potential trouble on horizon (eg. if I would like to access junction table from team controller - just load the Season model in Team controller? I think my anal file organization mind set would suffer enormously this way)

And what about the relation I've set up in MySQL? I connected the foreign keys in TeamsToSeasons with their primary key counterparts in respected tables, but I don't see where this comes in handy. I could have as easily just set up a new junction table and not tell MySQL anything about relationship since it all takes place in my model logic inside the CI application. Am I missing something?

PS. I am fully aware there are tools that would make this project development faster, but the emphasis is on the learning process.

Thank you for your time and answers!

Best Regards,


Messages In This Thread
Junction tables place in CI MVC arhitecture - by kamenjan - 05-14-2015, 02:14 AM

Theme © iAndrew 2016 - Forum software by © MyBB