pdo 连接数据库

 

 

 

'DB_DSN'=>'mysql:host=IP;port=3307;dbname=test;charset=utf8',

$db = 10.15.208.206;port=3307
/**
* 连接数据库
*/
public function connect($host, $user, $pass, $db)
{
try {
$this->_resource =new PDO("mysql:dbname=$db;host=$host", $user, $pass);
return $this->_resource;
}catch (PDOException $e){
return null;
}
//return null;
}
posted on 2020-05-08 11:22  bandbandme  阅读(138)  评论(0编辑  收藏  举报