当前位置:网站首页>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
边栏推荐
- Difference between like and regexp
- Tencent has written a few words, Ali has written them all for a month
- 移动app软件测试工具有哪些?第三方软件测评小编分享
- Reptile exercises (1)
- 免费在upic中设置OneDrive或Google Drive作为图床
- Redis master-slave synchronization
- Squid agent
- Llvm - generate addition
- G007-HWY-CC-ESTOR-03 华为 Dorado V6 存储仿真器搭建
- Detailed analysis of SQL combat of Niuke database (26-30)
猜你喜欢
Openfaas practice 4: template operation
Functions (Part I)
The wechat applet optimizes the native request through the promise of ES6
如何设计一个良好的API接口?
TLS / SSL protocol details (30) RSA, DHE, ecdhe and ecdh processes and differences in SSL
Mysql database explanation (10)
My raspberry PI zero 2W tossing notes record some problems encountered and solutions
What is the role of the full connection layer?
win10 任务栏通知区图标不见了
Detailed explanation of C language knowledge points -- data types and variables [1] - carry counting system
随机推荐
JUC学习记录(2022.4.22)
让阿里P8都为之着迷的分布式核心原理解析到底讲了啥?看完我惊了
Detailed explanation of C language knowledge points - data types and variables [2] - integer variables and constants [1]
Example of time complexity calculation
木木一路走好呀
kubernetes之常用Pod控制器的使用
regular expression
Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]
Llvm - generate local variables
Have you really learned the operation of sequence table?
setcontext getcontext makecontext swapcontext
Use of common pod controller of kubernetes
How to design a good API interface?
TLS / SSL protocol details (30) RSA, DHE, ecdhe and ecdh processes and differences in SSL
redis-shake 使用中遇到的错误整理
Share 20 tips for ES6 that should not be missed
Byte interview programming question: the minimum number of K
adobe illustrator 菜單中英文對照
A series of problems about the best time to buy and sell stocks
[thymeleaf] handle null values and use safe operators