当前位置:网站首页>通过 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
边栏推荐
- T2 icloud calendar cannot be synchronized
- Detailed explanation of C language knowledge points -- data types and variables [1] - carry counting system
- How to upload large files quickly?
- ffmpeg安装遇错:nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.
- Little red book timestamp2 (2022 / 04 / 22)
- 如果conda找不到想要安装的库怎么办PackagesNotFoundError: The following packages are not available from current
- MySQL InnoDB transaction
- My raspberry PI zero 2W tossing notes record some problems encountered and solutions
- MultiTimer v2 重构版本 | 一款可无限扩展的软件定时器
- 【thymeleaf】处理空值和使用安全操作符
猜你喜欢
Detailed explanation of C language knowledge points -- data types and variables [1] - carry counting system
Have you really learned the operation of sequence table?
Knn,Kmeans和GMM
About UDP receiving ICMP port unreachable
8.3 language model and data set
How does eolink help telecommuting
函数(第一部分)
2022年中国数字科技专题分析
How to upload large files quickly?
木木一路走好呀
随机推荐
8.5 concise implementation of cyclic neural network
C language super complete learning route (collection allows you to avoid detours)
【backtrader源码解析18】yahoo.py 代码注释及解析(枯燥,对代码感兴趣,可以参考)
Mysql连接查询详解
【thymeleaf】处理空值和使用安全操作符
Mysql database explanation (VII)
Example of time complexity calculation
The win10 taskbar notification area icon is missing
Deep learning - Super parameter setting
Detailed explanation of MySQL connection query
Adobe Illustrator menu in Chinese and English
填充每个节点的下一个右侧节点指针 II [经典层次遍历 | 视为链表 ]
自主作业智慧农场创新论坛
Comparaison du menu de l'illustrateur Adobe en chinois et en anglais
MySQL InnoDB transaction
Nacos program connects to mysql8 0+ NullPointerException
机器学习——逻辑回归
字节面试 transformer相关问题 整理复盘
2022年中国数字科技专题分析
HJ31 单词倒排