当前位置:网站首页>通过 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
边栏推荐
- Deep learning - Super parameter setting
- redis-shake 使用中遇到的错误整理
- Difference between like and regexp
- Mysql database explanation (10)
- Llvm - generate addition
- The life cycle of key value in redis module programming
- Use of common pod controller of kubernetes
- Fill in the next right node pointer II of each node [classical hierarchy traversal | regarded as linked list]
- MultiTimer v2 重构版本 | 一款可无限扩展的软件定时器
- Kubernetes详解(十一)——标签与标签选择器
猜你喜欢
Mysql database explanation (IX)
Detailed explanation of C language knowledge points -- first understanding of C language [1] - vs2022 debugging skills and code practice [1]
win10 任务栏通知区图标不见了
T2 iCloud日历无法同步
Krpano panorama vtour folder and tour
8.3 language model and data set
Have you really learned the operation of sequence table?
UML learning_ Day2
regular expression
The win10 taskbar notification area icon is missing
随机推荐
机器学习——逻辑回归
Reptile exercises (1)
js——實現點擊複制功能
nuxt项目:全局获取process.env信息
Ffmpeg installation error: NASM / yasm not found or too old Use --disable-x86asm for a clipped build
Educational Codeforces Round 127 A-E题解
买卖股票的最佳时机系列问题
ffmpeg安装遇错:nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.
API gateway / API gateway (III) - use of Kong - current limiting rate limiting (redis)
Do keyword search, duplicate keyword search, or do not match
JSON date time date format
Openstack theoretical knowledge
G007-HWY-CC-ESTOR-03 华为 Dorado V6 存储仿真器搭建
Flink datastream type system typeinformation
MySQL installation process (steps for successful installation)
Will golang share data with fragment append
Crawling fragment of a button style on a website
Detailed explanation of MySQL connection query
Introduction to dirty reading, unrepeatable reading and phantom reading
MySQL sync could not find first log file name in binary log index file error