How does the two CMS programs in the same directory do data synchronization?

Source: Internet
Author: User
There are now two CMS programs based on thinkphp, BBS and Easytalk:

    1. Http://127.0.0.1/bbs
    2. Http://127.0.0.1/bbs/easytalk

I think users in the BBS reply to the content of the post synchronization in the Easytalk, now think of two ways:
1. Assume that users reply to a post in the BBS by clicking Id=bbsreplybtn to perform Ajax replies, because there is no cross-domain, two times Ajax:

        $('#bbsReplyBtn').click(function(){        $.post('http://127.0.0.1/bbs',{reply:replyContent},function(){            $.post('http://127.0.0.1/bbs/easytalk',{reply:replyContent})            })        })        //这种方法要请求两次服务器,效率较低

2. Post the Http://127.0.0.1/bbs replycontent to Http://127.0.0.1/bbs/easytalk via curl on the server side.
Since there is not much in-depth research on thinkphp, does the great God have a better way to achieve data synchronization?

Reply content:

There are now two CMS programs based on thinkphp, BBS and Easytalk:

    1. Http://127.0.0.1/bbs
    2. Http://127.0.0.1/bbs/easytalk

I think users in the BBS reply to the content of the post synchronization in the Easytalk, now think of two ways:
1. Assume that users reply to a post in the BBS by clicking Id=bbsreplybtn to perform Ajax replies, because there is no cross-domain, two times Ajax:

        $('#bbsReplyBtn').click(function(){        $.post('http://127.0.0.1/bbs',{reply:replyContent},function(){            $.post('http://127.0.0.1/bbs/easytalk',{reply:replyContent})            })        })        //这种方法要请求两次服务器,效率较低

2. Post the Http://127.0.0.1/bbs replycontent to Http://127.0.0.1/bbs/easytalk via curl on the server side.
Since there is not much in-depth research on thinkphp, does the great God have a better way to achieve data synchronization?

The first method relies on the front end, and there is a possibility of omission. The second is similar, relies on the network, and curl reliability is not high.
You have to write it directly in PHP, and the user inserts content into two data tables when a or B has a commit action.

Since the requirement is data synchronization, you can operate directly in the database, Mysql for example, you can use the trigger mechanism to achieve cross-Library synchronization. Trigger use can refer to this answer:
http://segmentfault.com/q/1010000000485408#a-1020000000485714

Do not understand the landlord's meaning, two programs directly connected to the same database can?

The R method of TP can be used to call an interface method to insert the talk in the BBS after inserting the data successfully .... PS in TP 3.1 version R has bug pass multidimensional array data will be lost ..... Self-modification ..... Do not modify can use direct new and then call function pass parameter

  • 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.