$dsn="mysql:dbname=test;host=192.168.0.20;port=28336";
$db_user='test';
$db_pass='test';
//$db_user=$dbinfo['user'];
//$db_pass=$dbinfo['password'];
try{
$pdo=new PDO($dsn,$db_user,$db_pass);
var_dump($pdo);
$sql="SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%' OR Variable_name LIKE 'collation%'";//实验错误码
$res=$pdo->query($sql);//这个可以执行查询select
var_dump($res);//得到一个object(PDOStatement),遍历才可以输出
foreach($res as $row)
{
print_r($row);
}
}catch(PDOException $e){
echo '数据库连接失败'.$e->getMessage();
}