当前位置:网站首页>通过 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
边栏推荐
- MultiTimer v2 重构版本 | 一款可无限扩展的软件定时器
- SSH connects to the remote host through the springboard machine
- Advanced version of array simulation queue - ring queue (real queuing)
- 如果conda找不到想要安装的库怎么办PackagesNotFoundError: The following packages are not available from current
- 买卖股票的最佳时机系列问题
- 8.3 language model and data set
- Kubernetes详解(九)——资源配置清单创建Pod实战
- 8.4 realization of recurrent neural network from zero
- Flink DataStream 类型系统 TypeInformation
- JUC学习记录(2022.4.22)
猜你喜欢
Basic operation of sequential stack
Nuxt project: Global get process Env information
Set onedrive or Google drive as a drawing bed in upic for free
My raspberry PI zero 2W tossing notes record some problems encountered and solutions
What exactly does the distributed core principle analysis that fascinates Alibaba P8? I was surprised after reading it
机器学习——逻辑回归
What is the role of the full connection layer?
免费在upic中设置OneDrive或Google Drive作为图床
我的 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
Mysql database explanation (IX)
随机推荐
Basic operation of circular queue (Experiment)
Crawling fragment of a button style on a website
Baidu written test 2022.4.12 + programming topic: simple integer problem
MySQL sync could not find first log file name in binary log index file error
MySQL Basics
Flink datastream type system typeinformation
Have you really learned the operation of sequence table?
Advanced version of array simulation queue - ring queue (real queuing)
深度学习——超参数设置
Mysql database explanation (VII)
Mysql连接查询详解
Redis master-slave synchronization
Byte interview programming question: the minimum number of K
Five data types of redis
Llvm - generate addition
A series of problems about the best time to buy and sell stocks
Explanation of redis database (I)
Llvm - generate for loop
Functions (Part I)
For 22 years, you didn't know the file contained vulnerabilities?