当前位置:网站首页>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
边栏推荐
- API gateway / API gateway (III) - use of Kong - current limiting rate limiting (redis)
- PSYNC synchronization of redis source code analysis
- TLS / SSL protocol details (28) differences between TLS 1.0, TLS 1.1 and TLS 1.2
- 我的树莓派 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
- Three uses of kprobe
- Set onedrive or Google drive as a drawing bed in upic for free
- MySQL InnoDB transaction
- 2022年中国数字科技专题分析
- 8.3 language model and data set
- Fill in the next right node pointer II of each node [classical hierarchy traversal | regarded as linked list]
猜你喜欢
Deep learning - Super parameter setting
电脑怎么重装系统后显示器没有信号了
G007-hwy-cc-estor-03 Huawei Dorado V6 storage simulator construction
Have you learned the basic operation of circular queue?
8.4 realization of recurrent neural network from zero
Squid agent
Have you really learned the operation of sequence table?
木木一路走好呀
Detailed explanation of MySQL connection query
Detailed explanation of kubernetes (IX) -- actual combat of creating pod with resource allocation list
随机推荐
C语言超全学习路线(收藏让你少走弯路)
木木一路走好呀
Five data types of redis
YML references other variables
el-tree实现只显示某一级复选框且单选
Introduction to distributed transaction Seata
adobe illustrator 菜單中英文對照
ffmpeg安装遇错:nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.
The win10 taskbar notification area icon is missing
Basic operation of sequential stack
JUC learning record (2022.4.22)
js——實現點擊複制功能
Nacos program connects to mysql8 0+ NullPointerException
The life cycle of key value in redis module programming
深度学习调参的技巧
Detailed explanation of MySQL connection query
Openstack theoretical knowledge
JUC学习记录(2022.4.22)
Baidu written test 2022.4.12 + programming topic: simple integer problem
Crawling fragment of a button style on a website