本網站似乎提供您正在尋找的服務(對於一個價格)。
http://www.sqlparser.com/
它可以讓你解析並修改查詢和結果。然而,你想要做的似乎只需要幾行代碼來區分不同的用戶ID,所以即使mysql-proxy仍然在alpha中,你的需求很簡單,我只需要使用代理。
或者,您可以使用任何服務器端語言來獲取他們的user.id信息,然後根據該信息創建一個到適當數據庫的mysql連接。這裏有一些我拼湊在一起的php,它們在精神上做我認爲你想要做的事情。
</php
// grab user.id from wherever you store it
$userID = get_user_id($clientUserName);
$userpass = get_user_pass($clientUserName);
if ($userID % 4 == 0) { // every 4th user
$db = new mysqli('localhost', $clientUserName, $userPass, 'db4');
}
else if ($userID % 3 == 0) { // every 3th user
$db = new mysqli('localhost', $clientUserName, $userPass, 'db3');
}
else if ($userID % 2 == 0) { // every 2nd user
$db = new mysqli('localhost', $clientUserName, $userPass, 'db2');
}
else // every other user
$db = new mysqli('localhost', $clientUserName, $userPass, 'db1');
}
$db->query('SELECT * FROM ...;');
?>