i am a new beginner in cakephp. I am trying to do a deletion based on HABTM relationship, but failed. Please help me.
I have three tables: products
, users
and users_products
table.
one product can have many users and one user will have many products. The structure of users_products table is : id
, user_id
, product_id
, renew_id
.
I want to delete all datas in users_products
and products
table when renew_id
meet certain condition, but i do not want to touch anything on the users
table.
I am thinking to write a while loop to delete the records, but afraid will cause many queries and not using cakephp features.
How can i do this?