不要用多数据库获得价值

I have two connection string user DBO:

string1:

try {
$conn1 = new PDO('mysql:host=ip1;dbname=db1','root', '123456');
$conn1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} 
catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
} 

string2:

try {
$conn2 = new PDO('mysql:host=ip2;dbname=db2','root', '123456');
$conn2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} 
catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
} 

i using join query for join tb1 to tb2:

$stmt = $conn1->prepare(" select db1.*,db2.col1 from db1 left join db2 on db1.col1=db2.col2");
$stmt -> execute();
$result=$stmt->fetchAll();
if(count($result)){
foreach($result as $row){
echo $row[col1]";
}}
else{
Echo 'Not rows';                                          
}
}
catch(PDOException $e){
echo $e->getMessage();
}

It not work. i have tried $stmt = $conn1,$conn2-> prepare... and it not work too. i wrong something?

You did't mentioned Tables name in your join statement. I think you may want to do something like this :

SELECT * FROM db1.table_name as d1 LEFT JOIN db2.table_name as d2
ON d1.col1 = d2.col2

Try to replace your real Tables name with table_name in db1 and db2 in above statement.