都是连到同一个服务器,相同的用户密码,只是不同的库
代码1
<?php
$db_1 = mysqli_connect('localhost', 'root', '31343540');
mysqli_select_db($db_1, 'ftpunion');
$db_2 = mysqli_connect('localhost', 'root', '31343540');
mysqli_select_db($db_2, 'ftpunion_new');
var_dump(mysqli_fetch_assoc(mysqli_query($db_1, 'select database();')));
var_dump(mysqli_fetch_assoc(mysqli_query($db_2, 'select database();')));
#mysqli_select_db('ftpunion', $db_1);
var_dump(mysqli_fetch_assoc(mysqli_query($db_1, 'select database();')));
第二段代码
<?php
$db_1 = new mysqli('localhost', 'root', '31343540');
$db_1->select_db('ftpunion');
var_dump($db_1->query('select database();')->fetch_assoc());
$db_2 = new mysqli('localhost', 'root', '31343540');
$db_2->select_db('ftpunion_new');
var_dump($db_2->query('select database();')->fetch_assoc());
#$db_1->select_db('ftpunion');
var_dump($db_1->query('select database();')->fetch_assoc());
两个输出
G:\wwwroot\Test\mysql>php mysqli_select_db.php
array(1) {
["database()"]=>
string(8) "ftpunion"
}
array(1) {
["database()"]=>
string(12) "ftpunion_new"
}
array(1) {
["database()"]=>
string(8) "ftpunion"
}
G:\wwwroot\Test\mysql>php mysqli_select_db_oo.php
array(1) {
["database()"]=>
string(8) "ftpunion"
}
array(1) {
["database()"]=>
string(12) "ftpunion_new"
}
array(1) {
["database()"]=>
string(8) "ftpunion"
}
两次sleep的时候,netstat的结果
G:\Projects\sina\Slot>netstat -ano |find "368"
TCP 127.0.0.1:2538 127.0.0.1:3306 ESTABLISHED 3688
TCP 127.0.0.1:2539 127.0.0.1:3306 ESTABLISHED 3688
G:\Projects\sina\Slot>netstat -ano |find "283"
TCP 127.0.0.1:2618 127.0.0.1:3306 ESTABLISHED 2836
TCP 127.0.0.1:2619 127.0.0.1:3306 ESTABLISHED 2836
还有谁想说mysql_select_db 那个是个feature么 :x
No comments:
Post a Comment