当前位置:网站首页>通过 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
边栏推荐
猜你喜欢

Functions (Part I)

API gateway / API gateway (II) - use of Kong - load balancing

Differential privacy (background)

Sword finger offer (1) -- for Huawei

自主作业智慧农场创新论坛

What is the role of the full connection layer?

win10 任务栏通知区图标不见了

Share 20 tips for ES6 that should not be missed

Openstack command operation

regular expression
随机推荐
Async keyword
How does eolink help telecommuting
ffmpeg安装遇错:nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.
Async void caused the program to crash
MySQL sync could not find first log file name in binary log index file error
C language super complete learning route (collection allows you to avoid detours)
Comparaison du menu de l'illustrateur Adobe en chinois et en anglais
Crawling fragment of a button style on a website
Thinkphp5 + data large screen display effect
Mysql database explanation (10)
Llvm - generate local variables
Introduction to distributed transaction Seata
Three uses of kprobe
asp. Net method of sending mail using mailmessage
Basic operation of sequential stack
The win10 taskbar notification area icon is missing
Sword finger offer (2) -- for Huawei
Reptile exercises (1)
函数(第一部分)
YML references other variables