当前位置:网站首页>通過 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
边栏推荐
- Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]
- 8.5 concise implementation of cyclic neural network
- Nacos program connects to mysql8 0+ NullPointerException
- 8.4 realization of recurrent neural network from zero
- Llvm - generate addition
- Set onedrive or Google drive as a drawing bed in upic for free
- Grep was unable to redirect to the file
- YML references other variables
- Nacos程序连接MySQL8.0+ NullPointerException
- Detailed explanation of C language knowledge points -- first understanding of C language [1] - vs2022 debugging skills and code practice [1]
猜你喜欢

Byte interview programming question: the minimum number of K

Tun model of flannel principle

My raspberry PI zero 2W toss notes to record some problems and solutions

Mysql连接查询详解

木木一路走好呀

How to use OCR in 5 minutes

22年了你还不知道文件包含漏洞?

让阿里P8都为之着迷的分布式核心原理解析到底讲了啥?看完我惊了

regular expression

Krpano panorama vtour folder and tour
随机推荐
Functions (Part I)
Introduction to dirty reading, unrepeatable reading and phantom reading
C language super complete learning route (collection allows you to avoid detours)
G007-hwy-cc-estor-03 Huawei Dorado V6 storage simulator construction
Error: unable to find remote key "17f718f726"“
8.5 concise implementation of cyclic neural network
MySQL installation process (steps for successful installation)
Use of common pod controller of kubernetes
【Leetcode-每日一题】安装栅栏
Mysql database explanation (8)
Mysql连接查询详解
Llvm - generate addition
Share 3 tools, edit 5 works at home and earn more than 400
MySQL query library size
About UDP receiving ICMP port unreachable
How to design a good API interface?
调度系统使用注意事项
Do keyword search, duplicate keyword search, or do not match
【thymeleaf】处理空值和使用安全操作符
T2 icloud calendar cannot be synchronized