0

related to another question that no body answerd.

in another question that i asked before some person helped me but now i am stuck in another situation.

ok now i want to know is there any way in some table we use from two seperate engine like 2 column uid and username has myisam engine and lastlogin which is a timestamp has a memory engine in use.

because i thought its not possible i tryed to make a table onlineusers(MEMORY ENGINE) in database with two columns one was uid and another one was lastlogin and then when user wants to login i check database like this and insert if user not exist

$myquery = mysql_query('SELECT COUNT(1) FROM `onlineusers` WHERE uid="'. $row['uid'] . '"');

if(mysql_result($myquery,0) == 0){
    $data['uid'] = $row['uid'];             
    $db->insert("onlineusers",$data);
}else{
    updateStatus($row['uid']);
}

and update status function is like this

function updateStatus($uid){
    $db = DATABASE::obtain();
    $query = mysql_query("UPDATE `onlineusers` set `lastvisit`=now() WHERE uid='".$db->escape($uid)."'");
}

but when i thought about this i figured it out when we restart our server then table of onlineusers will be empty and what will happen for users with cookies set logged in?

then i have to change update function to use two seperate query first query check if uid exist in onlineuses then if not we will insert into it or if exist we have to update timestamp..

now i have another question to ask. using this method is faster to check if exist or not and then update it with updatestatus function which has memory engine ... or just create some timestamp cloumn in my users table and update it on each page check that have myisam engine??

4

1 回答 1

0

您正在尝试做的事情,即在同一张桌子上使用两个单独的引擎听起来是不可能的。单个引擎控制单个表作为 MySQL 最基本的层次。有可能解决这个问题,但这并不明智。你可以编辑源代码,但这太疯狂了。如果您担心性能,那么您可以将您的表拆分为多个表,以便在您需要的表上使用您需要的引擎。否则,您可以使用像 mem cache(我推荐)这样的缓存框架,它可以通过缓存来提高性能,但是您需要它。Mem 缓存是一个经过良好测试的 PHP 工具,听起来就像您需要的一样。祝你好运。

于 2012-11-02T19:59:04.403 回答