Question

I want to know how to handle mysql tables created with constraints in joomla. for a example,

theater_table
id , name, description, image, address, tel, fax ,email

theater_facility_table
id, theater_id, facility_id

facility_table
id, name, description, image

Facility table already filled with data and id is the primary key. When creating a theater I am adding facilities to it. I created facility and theater JTables.

Do I have to create theater_facility JTable too?

Using theater Model class how I insert data to theater_facility table. I know I can insert data after theater stored successfully creating and calling storeTheaterFacility() method where it contains insert query to save required information. But I feel it can't be a good method to do so. Please help me to solve this.

Was it helpful?

Solution

Depending on how you implemented the theater - facility relationship, you can handle insering new data in different parts of your code. I mean, if for example your JTable class (the one that loads theaters) is loading/saving the theater-facilities relationship too, then the same class should delete it. May be you can take a look at other components (for example, com_content, which relates an article to a category, or K2, where you can have multiple tags related to multiple "items"(articles)), so you can take a look on how do these components handle these kind of relationships. Another important point you shouldn't forget is to update your facility model / table to delete records from the relationship table upon facility deleting.

I hope it helped!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top