pdo 连接数据库

时间:2020-05-08 13:06:36   收藏:0   阅读:49

 

 

 

‘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;
}

原文:https://www.cnblogs.com/bandbandme/p/12849430.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!