Home  >  Article  >  Backend Development  >  PHP uses pdo to connect to mssql server database instance, pdomssql_PHP tutorial

PHP uses pdo to connect to mssql server database instance, pdomssql_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:10:471035browse

php uses pdo to connect to the mssql server database instance, pdomssql

The example in this article describes the method of using php's pdo to connect to Microsoft's mssql server database. It is shared with everyone for your reference. The specific implementation method is as follows:

Copy code The code is as follows:
$dsn = 'mssql:dbname=bookStore_demo;host=192.168.1.106';
$user = 'sa';
$password = '123';
//mssql_connect('192.168.1.106','sa','123');
//echo 22;
try {
// echo 11;
$dbh = new PDO($dsn, $user, $password);

} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
//$sql = 'select * from article';
$sth = $dbh->query($sql);
$result = $sth->fetchAll();

var_dump($result);

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/932487.htmlTechArticlephp uses pdo to connect to mssql server database instance, pdomssql This example describes the use of php's pdo to connect to Microsoft's mssql server The database method is shared with everyone for your reference. Specific actual...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn