我有一个网站,使用一个名为"site1"的数据库.我打算将另一个站点放在同一台服务器上,该站点也将使用"site1"中的一些表.
因此,我应该使用三个不同的数据库,如"site1"(对于第一个站点特定数据),"site2"(对于第二个站点特定数据)和"general"(对于常见表).其中将存在数据库general和site1和site2之间的连接语句.或者我应该将所有表放在一个数据库中?
哪种做法最好?每种情况下表现如何不同?我正在使用MySQL.那么这种情况尤其适用于MySQL呢?
提前致谢...
有一个javascript代码,其中包含messageList保留消息列表的变量,可以通过以下函数更新updateMessageList():
var messageList=[]; //contains list of messages
function updateMessageList(id, lastUpdate); //updates messageList item for given id
//at some point while running
mesasgeList=[
{id:1, lastUpdate:1371650818000},
{id:2, lastUpdate:1371650821000},
.....
]
Run Code Online (Sandbox Code Playgroud)
如果两个不同的源updateMessageList()同时为同messageList一项调用函数会发生什么.假设消息的一个更新id:1来自客户端(当前用户更新消息)而另一个来自服务器也用于消息id:1(另一个用户更新消息).然后他们将尝试同时访问和修改messageList[0].lastUpdate属性.
在Source 1中:当客户端更新消息表单时,submit事件触发该功能 handleReply()
function handleReply(event) {
.....
var id=event.currentTarget.find('input[name="id"]').val();
//form has an hidden input for id of the message
var d = new Date();
updateMessageList(id, d.getTime());
.....
}
Run Code Online (Sandbox Code Playgroud)
在Source 2中:JS对服务器进行AJAX调用以检查是否有任何更新,而不是运行updateMessages()函数作为回报
//server sends following JSON data:{id:1, …Run Code Online (Sandbox Code Playgroud)