1
我現在有一個數據庫文件的數據庫連接我包括建立一個數據庫連接:包括一個單獨的文件
db.php中:
$dbs = array(
"127.0.0.1",
"127.0.0.3",
"127.0.0.2",
);
if(!$con){
$con = mysql_connect($dbs[rand(0,2)],"user_login","password") or die('Could not connect: ' . mysql_error());
}
然而,當我嘗試有時包括它做查詢時,它會返回一個空的結果:
include("db.php");
mysql_select_db("database_table", $con);
$result = mysql_query("SELECT * FROM users where email='[email protected]'");
while($row = mysql_fetch_array($result)){$id = $row['email'];break;}
奇怪的是,如果我修改初始db.php中象這樣連接,它的作品(非隨機化吧): db.php中:
if(!$con){
$con = mysql_connect("127.0.0.1","user_login","password") or die('Could not connect: ' . mysql_error());
}
這裏有什麼解釋嗎?他們如何連接有什麼不同?
謝謝
你怎麼可能會隨機挑選一個數據庫 –
隨機挑選的加萊拉集羣 – Kevin
一個節點,我不能想象這是該方法加萊拉recomends –