当前位置:网站首页>Connect PHP to MySQL via PDO ODBC
Connect PHP to MySQL via PDO ODBC
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
边栏推荐
- 今日睡眠质量记录76分
- C语言超全学习路线(收藏让你少走弯路)
- Functions (Part I)
- Difference between like and regexp
- G007-hwy-cc-estor-03 Huawei Dorado V6 storage simulator construction
- Comparaison du menu de l'illustrateur Adobe en chinois et en anglais
- Thinkphp5 + data large screen display effect
- Analysis of common storage types and FTP active and passive modes
- 重定向和请求转发详解
- 【Leetcode-每日一题】安装栅栏
猜你喜欢
Detailed explanation of redirection and request forwarding
How to use OCR in 5 minutes
深度学习——超参数设置
让阿里P8都为之着迷的分布式核心原理解析到底讲了啥?看完我惊了
Knn,Kmeans和GMM
nuxt项目:全局获取process.env信息
字节面试 transformer相关问题 整理复盘
8.4 realization of recurrent neural network from zero
Openstack theoretical knowledge
Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]
随机推荐
MySQL Basics
免费在upic中设置OneDrive或Google Drive作为图床
Crawling fragment of a button style on a website
我的 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
adobe illustrator 菜單中英文對照
How to write the keywords in the cover and title? As we media, why is there no video playback
Introduction to distributed transaction Seata
Lotus DB design and Implementation - 1 Basic Concepts
Comparaison du menu de l'illustrateur Adobe en chinois et en anglais
Little red book timestamp2 (2022 / 04 / 22)
今日睡眠质量记录76分
JSON date time date format
Will golang share data with fragment append
API gateway / API gateway (II) - use of Kong - load balancing
移动app软件测试工具有哪些?第三方软件测评小编分享
Modify the default listening IP of firebase emulators
Openstack command operation
Grep was unable to redirect to the file
Error: unable to find remote key "17f718f726"“
Openstack theoretical knowledge