There are now two CMS programs based on thinkphp, BBS and Easytalk:
- Http://127.0.0.1/bbs
- 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:
- Http://127.0.0.1/bbs
- 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