当前位置:网站首页>通过 PDO ODBC 将 PHP 连接到 MySQL
通过 PDO ODBC 将 PHP 连接到 MySQL
2022-04-23 15:25: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://blog.csdn.net/allway2/article/details/124361655
边栏推荐
- Detailed explanation of C language knowledge points -- data types and variables [1] - carry counting system
- Five data types of redis
- Modify the default listening IP of firebase emulators
- Comparaison du menu de l'illustrateur Adobe en chinois et en anglais
- C语言超全学习路线(收藏让你少走弯路)
- Openstack theoretical knowledge
- JUC学习记录(2022.4.22)
- Elk installation
- Do keyword search, duplicate keyword search, or do not match
- 自主作业智慧农场创新论坛
猜你喜欢

8.5 concise implementation of cyclic neural network

Differential privacy (background)

8.2 text preprocessing

字节面试 transformer相关问题 整理复盘
![Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]](/img/c6/5241de0d670da3dae136a3047c6160.jpg)
Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]
![Detailed explanation of C language knowledge points - data types and variables [2] - integer variables and constants [1]](/img/d4/9ee62772b42fa77dfd68a41bde1371.png)
Detailed explanation of C language knowledge points - data types and variables [2] - integer variables and constants [1]

Sword finger offer (2) -- for Huawei

Sword finger offer (1) -- for Huawei

MySQL InnoDB transaction

Advanced version of array simulation queue - ring queue (real queuing)
随机推荐
Elk installation
fatal error: torch/extension.h: No such file or directory
My raspberry PI zero 2W tossing notes record some problems encountered and solutions
8.3 language model and data set
JUC learning record (2022.4.22)
How to design a good API interface?
UML learning_ Day2
免费在upic中设置OneDrive或Google Drive作为图床
Llvm - generate for loop
【thymeleaf】处理空值和使用安全操作符
字节面试 transformer相关问题 整理复盘
Tencent has written a few words, Ali has written them all for a month
Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]
C语言超全学习路线(收藏让你少走弯路)
自主作业智慧农场创新论坛
Mysql连接查询详解
网站某个按钮样式爬取片段
Little red book timestamp2 (2022 / 04 / 22)
机器学习——逻辑回归
Reptile exercises (1)