How to Avoid table Association in PHP

Source: Internet
Author: User
In PHP, how do I deal with the PHPcode of the associated table? for example, A user table is used, A user is added to the comment table, and user A is added to the favorites table, if you delete user A, post published by user A, post comments, and favorites, how should you deal with similar problems? /****************** How to deal with joined tables in PHP
PHP code
  For example, User A has published an article, commented by user B, and added to user C. If user A is deleted, how to deal with similar problems in the comments and collections of articles? /*************************************** **/In addition, how does php implement joined table operations ~ Add, update, and delete


------ Solution --------------------
Delete the article and delete the corresponding comments and favorites.

Multiple tables can be connected. For example, left join/right join/inner join is recommended to check mysql multi-table operations.
------ Solution --------------------
Multi-table operations: table Sharding is performed on one table;
Only query is associated.
Http://user.qzone.qq.com/937461184/blog/1330412851
------ Solution --------------------
You can delete the mysql table, that is, when you delete an article, you are also deleting comments and favorite articles.
------ Solution --------------------
If you have uploaded files and are commented by users, add them to favorites.
If you delete this file. So other users' comments and collections should not be available. This is the first consideration.
If you think this is all deleted. Delete a trigger based on the id or create a trigger.
If you don't think it is necessary to delete it, then ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.