当前位置:网站首页>Connect PHP to MySQL via PDO ODBC
Connect PHP to MySQL via PDO ODBC
2022-04-23 15:26:00 【allway2】
<?php
$hostname = "localhost";
$database = "db";
$username = "root";
$password = "root";
try {
$pdo = new PDO("odbc:Driver={MySQL ODBC 3.51 Driver};host=$hostname;database=$database", $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT id,name,city FROM mytable";
$stmt = $pdo->query($sql);
while ($row = $stmt->fetch()) {
print( $row[0] . "-" . $row[1] . "-" . $row[2] . "\r\n");
}
} catch (PDOException $e) {
echo $e->getMessage();
exit;
}
# close the connection
$dbh = null;
?>
版权声明
本文为[allway2]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231525131224.html
边栏推荐
- tcp_ Diag kernel related implementation 1 call hierarchy
- How to upload large files quickly?
- Share 3 tools, edit 5 works at home and earn more than 400
- Leetcode学习计划之动态规划入门day3(198,213,740)
- Difference between like and regexp
- Mysql连接查询详解
- How to design a good API interface?
- Subnet division of flannel principle
- Educational Codeforces Round 127 A-E题解
- SSH connects to the remote host through the springboard machine
猜你喜欢
Thinkphp5 + data large screen display effect
Openstack theoretical knowledge
The wechat applet optimizes the native request through the promise of ES6
Basic operation of sequential stack
群体智能自主作业智慧农场项目启动及实施方案论证会议
T2 iCloud日历无法同步
推荐搜索 常用评价指标
Detailed explanation of C language knowledge points -- data types and variables [1] - carry counting system
Advanced version of array simulation queue - ring queue (real queuing)
setcontext getcontext makecontext swapcontext
随机推荐
Differential privacy (background)
Baidu written test 2022.4.12 + programming topic: simple integer problem
Subnet division of flannel principle
What exactly does the distributed core principle analysis that fascinates Alibaba P8? I was surprised after reading it
Introduction to distributed transaction Seata
The wechat applet optimizes the native request through the promise of ES6
js——實現點擊複制功能
码住收藏▏软件测试报告模板范文来了
MySQL query library size
Squid agent
Wechat applet customer service access to send and receive messages
22年了你还不知道文件包含漏洞?
Fill in the next right node pointer II of each node [classical hierarchy traversal | regarded as linked list]
【Leetcode-每日一题】安装栅栏
TLS / SSL protocol details (30) RSA, DHE, ecdhe and ecdh processes and differences in SSL
For 22 years, you didn't know the file contained vulnerabilities?
买卖股票的最佳时机系列问题
[thymeleaf] handle null values and use safe operators
Mysql database explanation (8)
深度学习——超参数设置