0

My relationship is like

             Post<HABTM>Tag

When I add a new post and corresponding tags it is saving in posts table and tags table and save the ids of both in posts_tags table. Everything is working fine with cakephp HABTM, but now I want to delete a post. I wrote the code:

           $this->Post->delete($id);

this deleted the corresponding post with given id and delete the association in the posts_tags table that also working fine. I want to delete the post and corresponding tags in the tags table and values in the mapping table posts_tags. How we can do this in a single shot? Is there any way? Otherwise tell me any solution..I am confused

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
SibinF
  • 385
  • 1
  • 7
  • 25
  • Accoriding to this http://book.cakephp.org/2.0/en/models/deleting-data.html you should be able to delete related data by calling it just like that. Please provide your model code and database structure. – makallio85 Mar 29 '14 at 17:45
  • What you are asking is not realistic. If you delete a Tag with Post then the other posts depends on that Tag will mother less..... – Fazal Rasel Apr 06 '14 at 17:28
  • @Fazal Rasel ya you r right. the real problem is i have a user table,employee table and address table, each user and employee have 1 or more address. so now i have made user HABTM address and employeee HABTM address. so when i delete the user, it is deleting the record of addresses_users table and users table but not in the address table . that is my problem. is there any way..? please help me – SibinF Apr 10 '14 at 09:53

0 Answers0