$bbs = new PDO("odbc:MSSQLServer",
$username_bbs,
$password_bbs
$bbs = new PDO('odbc:driver={SQL Server};Server=127.0.0.1;Database=qq;','sa','123');
$server='127.0.0.1';
$userid='sa';
$pw='123';
$dbname='test';
$constring='odbc:driver={SQL Server};Server='.$server.';Database='.$dbname.';';
$dbcon = new PDO($constring,$userid,$pw);
$dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
pdo mysql
new PDO("mysql:host=localhost;dbname=db_demo","root","");
默认不是长连接,若要使用数据库长连接,需要在最后加如下参数:
new PDO("mysql:host=localhost;dbname=db_demo","root","","array(PDO::ATTR_PERSISTENT => true) ");
注意:php.ini里的extension=php_pdo_odbc.dll去掉分号注释才可以用。