当前位置:网站首页>通過 PDO ODBC 將 PHP 連接到 MySQL
通過 PDO ODBC 將 PHP 連接到 MySQL
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
边栏推荐
- 如果conda找不到想要安装的库怎么办PackagesNotFoundError: The following packages are not available from current
- Lotus DB design and Implementation - 1 Basic Concepts
- 自主作业智慧农场创新论坛
- Async keyword
- Basic operation of circular queue (Experiment)
- SSH connects to the remote host through the springboard machine
- HJ31 单词倒排
- Detailed explanation of redirection and request forwarding
- Common interview questions of operating system:
- On the day of entry, I cried (mushroom street was laid off and fought for seven months to win the offer)
猜你喜欢
T2 icloud calendar cannot be synchronized
What exactly does the distributed core principle analysis that fascinates Alibaba P8? I was surprised after reading it
My raspberry PI zero 2W toss notes to record some problems and solutions
Wechat applet customer service access to send and receive messages
Differential privacy (background)
木木一路走好呀
G007-HWY-CC-ESTOR-03 华为 Dorado V6 存储仿真器搭建
如何设计一个良好的API接口?
Tun model of flannel principle
我的树莓派 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
随机推荐
X509 certificate cer format to PEM format
tcp_ Diag kernel related implementation 1 call hierarchy
机器学习——逻辑回归
Openstack command operation
Tencent has written a few words, Ali has written them all for a month
C language super complete learning route (collection allows you to avoid detours)
On the day of entry, I cried (mushroom street was laid off and fought for seven months to win the offer)
Use of common pod controller of kubernetes
MultiTimer v2 重构版本 | 一款可无限扩展的软件定时器
Will golang share data with fragment append
HJ31 单词倒排
Ffmpeg installation error: NASM / yasm not found or too old Use --disable-x86asm for a clipped build
MySQL InnoDB transaction
Detailed explanation of C language knowledge points -- data types and variables [1] - carry counting system
Share 20 tips for ES6 that should not be missed
js——實現點擊複制功能
Async void caused the program to crash
Deep learning - Super parameter setting
Nacos程序连接MySQL8.0+ NullPointerException
Common interview questions of operating system: