Associative delete with many models

Szczypka 30 Jan, 2015
Thanks for the software. It really helps! Great job.

I have a connection with many models. All with relation: belongsTo and associated with the main model so I left the Accociated Model empty. Beside these I have the foreign key and primary key set for each model. It works with displaying the data in views.

I set the Associative delete to Yes. I added the _DELETE_ action into the list page.
I can see the data from the main model is deleted correctly from the database. However, all the associated models data is untouched by the Delete action.
Am I missing something in my settings?
Max_admin 04 Feb, 2015
Hi Szczypka,

Deleting the primary model will delete all children models records, IF the relation is "hasOne" or "hasMany", but not if its belongsTo.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Szczypka 05 Feb, 2015
Thanks Max,
I understand.
with the 'belongsTo' I set only the Foreign key and Primary key fields and I'm able to access all fields that I need. However when I simply changed the Relation to 'hasOne' I get nothing.

Is there a different way to configure the models when working with 'hasOne' relationship?
Max_admin 05 Feb, 2015
Answer
1 Likes
The relation depends on the real relation between the 2 tables, so in some cases you can only set it up as "belongsTo", in case the main table is the "slave" table.
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin 07 Feb, 2015
1 Likes
More info here, the slave table is the one which has the "foreign key", and the framework is built so that deleting a record from the salve table should not delete a record from the master table, only the opposite way works.

So if you want to delete the master table's record then you need PHP code to do that OR you need to change the relation between the 2 tables.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Szczypka 09 Feb, 2015
Thanks Max,
In the end I wrote my own PHP code to delete data from the tables.

Regards,
Rafal
This topic is locked and no more replies can be posted.