odbc连接数据库,odbc数据库
odbc连接数据库,odbc数据库
php操作数据库有很多种方式,如mysql,mysqli,odbc,pdo等。MySQL 是 PHP 操作 MySQL 数据库最原始的 Extension。MySQLi 的 i 代表 Improvement ,提供了相对进阶的功能,就 Extension 而言,本身也增加了安全性,这都只是操作特定种类的数据库的,当你更换其他类型的数据库时又得使用其他类型数据库的操作方法来操作数据库,也就是得重写代码,这是很麻烦的。有没有一种方法可以是通用型的,使得可以一次编写多次使用,兼容各种数据库呢?答案当然是肯定的,那就是obbc以及pdo了。pdo是php 5新出的用来操作各种数据库的扩展,是专属于php的,就类似于Java的jdbc。这个后面再讲。现在先讲一讲odbc。
什么是ODBC?
ODBC 是一个软件驱动程序系统,用于连接编程语言与数据存储。ODBC 是一个免费的开放源码系统,出现于 1992 年,它试图通过编程语言和数据库查询访问(SQL 标准化)来标准化连接方法,比如功能和配置。
ODBC 的作用是充当接口或连接器,它具有双重设计目标:首先,对于 ODBC 系统,它充当的是编程语言系统,其次,对于数据存储系统,它充当的是 ODBC 系统。所以,ODBC 需要一个 “对 ODBC 而言是编程语言” 的驱动程序(例如 PHP-ODBC 库)和一个 “对数据存储系统而言是 ODBC” 的驱动程序(比如 MySQL-ODBC 库)。除了 ODBC 系统本身之外,ODBC 还可以处理数据源的配置,允许数据源和编程语言之间存在模糊性。
怎么使用odbc?
当使用odbc时, PHP 开发变得 “与数据库连接器无关”。它对数据库(比如 MySQL、PostgreSQL、SQLite、Microsoft SQL Server®、IBM® DB2®、Sybase、OpenLink Virtuoso、FileMaker 和 Microsoft Office® Access®)使用像 odbc_query()
这样的函数。还可以将 ODBC 用于 CSV 和 Excel 电子表格,具体取决于正确的 ODBC 驱动程序设置。下面看看怎么使用:
1.首先odbc扩展并开启,通过phpinfo()查看到该模块并且状态为enabled;
2.连接到 ODBC
1 |
|
1 |
|
3.取回记录
1 |
|
1 |
|
1 |
|
4.从记录中取回字段
1 2 3 4 5 6 7 |
|
5.关闭 ODBC 连接
1 2 3 |
|
注:其他操作函数:http://php.net/manual/zh/ref.uodbc.php
ODBC 实例
下面的实例展示了如何首先创建一个数据库连接,接着创建一个结果集,然后在 HTML 表格中显示数据。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to read the first few records in a database using PHP? When developing web applications, we often need to read data from the database and display it to the user. Sometimes, we only need to display the first few records in the database, not the entire content. This article will teach you how to use PHP to read the first few records in the database and provide specific code examples. First, assume that you have connected to the database and selected the table you want to operate on. The following is a simple database connection example:

In Java programs, connecting to the database is a very common operation. Although ready-made class libraries and tools can be used to connect to the database, various abnormal situations may still occur during program development, among which SQLException is one of them. SQLException is an exception class provided by Java. It describes errors that occur when accessing the database, such as query statement errors, table non-existence, connection disconnection, etc. For Java programmers, especially those using JDBC (Java Data

Go language connects to the database by importing the database driver, establishing a database connection, executing SQL statements, using prepared statements and transaction processing. Detailed introduction: 1. Import the database driver and use the github.com/go-sql-driver/mysql package to connect to the MySQL database; 2. Establish a database connection and provide the database connection information, including the database address, user name, password, etc. Establish a database connection and so on through the sql.Open function.

Using Go language to connect to the database: Improving application performance and efficiency As applications develop and the number of users increases, data storage and processing become more and more important. In order to improve the performance and efficiency of applications, properly connecting and operating the database is a crucial part. As a fast, reliable, and highly concurrency development language, Go language has the potential to provide efficient performance when processing databases. This article will introduce how to use Go language to connect to the database and provide some code examples. Install database driver using Go language

Steps and techniques for implementing product inventory in PHP In the e-commerce industry, product inventory management is a very important task. Timely and accurate inventory counting can avoid sales delays, customer complaints and other problems caused by inventory errors. This article will introduce the steps and techniques on how to use PHP to implement product inventory counting, and provide code examples. Step 1: Create a database First, we need to create a database to store product information. Create a database named "inventory" and then create a database named "prod

Learn Go language: basic knowledge of connecting to databases, specific code examples are required. Go language is an open source programming language. Its simple and efficient features make it loved and used by more and more developers. During the development process, it is often necessary to establish a connection with the database to perform operations such as reading, writing, updating, and deleting data. Therefore, learning how to connect to a database in Go language is a very important skill. Database driver In the Go language, a database driver is required to connect to the database. At present, the main database drivers of Go language are:

Installing and configuring PHP on Ubuntu systems to connect to MSSQL databases is a common task, especially when developing web applications. In this article, we will introduce how to install PHP, MSSQL extensions and configure database connections on Ubuntu systems, while providing specific code examples. Step 1: Install PHP and MSSQL extensions Install PHP First, you need to make sure that PHP is installed on your Ubuntu system. PHP can be installed with the following command: sudoaptu

Title: What are the important functions of MySQL’s Jar package? MySQL is a popular relational database management system that many Java developers use when developing applications. In order to interact with the MySQL database in a Java project, the official Java driver Jar package provided by MySQL is usually used. MySQL's Jar package has many important functions. This article will introduce some of them and provide specific code examples. 1. Connect to MyS
