Home Database Mysql Tutorial MySQL可用的API[组图]_MySQL

MySQL可用的API[组图]_MySQL

Jun 01, 2016 pm 01:56 PM
app develop interface

    5.1MySQL可用的API

    为了方便应用程序的开发,MySQL提供了用C 编程语言编写的客户机库,它允许从任何C 程序的内部访问MySQL数据库。客户机库实现应用程序编程接口( A P I),API 定义客户机程序如何建立和执行与服务器的通信。

    然而,使用C 来编写MySQL程序并不受限制。许多其他语言处理器本身也是由C 编写的,或具有使用C库的能力,所以MySQL客户机库提供了这个方法,由此, MySQL对这些语言的约束可以建立在C API 的上面。这就为与MySQL服务器通信而编写应用程序提供了许多选择。客户机程序的API 是用Perl、PHP、Java、Python、C++、Tcl 和其他一些语言编写的。有关最新的清单,请查看MySQL参考指南或MySQLWeb 站点,因为有时会增加用新语言编写的A P I。

    每种语言约束都定义自己的接口,特别是访问MySQL的规则。这里没有足够的时间来讨论MySQL可使用的每种A P I,我们只讲述最流行的三种:

    ■ C 客户机库A P I。这是MySQL的基本编程接口。

    ■ Perl 通用目标脚本语言的DBI(数据库接口) A P I。DBI 是作为与其他模块在DB D(数据库驱动程序)级接口的Perl 模块来实现的,每个模块都提供对特定类型的数据库引擎的访问(当然,我们将讨论的特定的DBD 模块也提供对MySQL的支持)。DBI 对MySQL的最普遍用法是编写由命令行来调用的独立的客户机,以及试图由Web 服务器调用的脚本来提供Web 对MySQL的访问。

    ■ PHP API。PHP 是一种脚本语言,它提供了在Web 页中嵌入程序的一种便利的方法。在发送以前,这样的页面由PHP来处理,它允许这些脚本生成动态的内容,如在页面中包括MySQL查询的结果。“PHP”原始的意思是个人主页( Personal Home Page),但是PHP 的成长已经远远超过它简单的原始功能。PHP Web 站点现在使用的这个名称表示“PHP:超文本预处理程序( Hypertext Preprocessor)”,它像GNU (是GUN而不是UNIX )一样以同样的方式自我引用。

    使用他人成果

    当标准的MySQL客户机不能满足需要时,您并不总是需要编写自己的程序。其他一些人一直编写程序,而这些程序中有许多是可共享得到的。请参阅附录I 中的一些样例。只要找到几个就能节省您的许多工作。

    以上这三种A P I都有专门章节详细说明。本章只提供对API 比较的概述,用来说明它们的基本特征,并给出对特定的应用程序可能选择某个而不是其他API 的原因。

    当然,不必只考虑某个API,应了解每个API,并用可以明智选择适合自己的API。在包括若干组件的大项目中,可能使用多个API,多种语言,这取决于每个子任务适合哪一种语言。

    对于试图使用的任何一种API,如果需要得到必需的软件,请参阅附录A。

    5.1.1C API

    CAPI 用于编译C 程序上下文环境内部。它是一种客户机库,提供可用来与MySQL服务器对话的最低级别的接口――具有创建与服务器通信所需的能力。DBI 和PHP 的前身DBI 的Perl 前身是Mysqlperl 模块M y s q l . p m。这个模块不再被支持,而且不应该用于新的MySQL的开发。有一件事需要明白,Mysqlperl 是依赖于MySQL的,但DBI 不是。如果编写MySQL的Perl 应用程序,然后,决定想用另外一种数据库引擎来使用它们,则移植DBI 脚本比Mysqlperl 脚本更容易一些,因为它们很少依赖于特定的数据库引擎。如果获取了访问MySQL的一段Perl 脚本,并发现它是用Mysqlperl 而不是DBI 编写的,则仍然可以使用DBI。DBI 包括了对Mysqlperl 的仿真支持,因此不需要安装两个程序包。PHP 3 的前身是PHP/FI 2.0 (F I代表“ form interpreter ,即格式解释程序”)。像Mysqlperl 一样,PHP / F I也是过时的,所以我们就不再进一步讨论它了。

  MySQLC API 的起源如果已经有编写mSQL RDBMS 程序的经验,那么将注意到MySQLC API 类似于mSQL 相应的C API。当MySQL的开发者们开始实现他们的SQL 引擎时,许多有用的共享实用程序可用于m SQL。要想花费最小的难度将那些mSQL 实用程序移植为MySQL的
实用程序是可能的,可有意地将MySQLAPI设计为与mSQL API 类似(MySQL甚至带有与mSQL API 函数名称相应的MySQL名称的简单的文本替代品的msql2mysql脚本。这个操作相对烦琐,实际上也照顾了许多涉及为使用MySQL而转换mSQL 程序的工作)。

    MySQL分发包提供的C 客户机是基于这个API 的。C 客户机库也作为MySQL对其他语言约束的基础来提供服务,但Java API 是一个例外。例如,通过连接MySQLC 客户机库代码(这个过程在附录A中通过DBI 和PHP 安装指导来举例说明),MySQL可用Perl DBI 模块专有的MySQL驱动程序和PHP 代码。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to connect Apple Vision Pro to PC How to connect Apple Vision Pro to PC Apr 08, 2024 pm 09:01 PM

The Apple Vision Pro headset is not natively compatible with computers, so you must configure it to connect to a Windows computer. Since its launch, Apple Vision Pro has been a hit, and with its cutting-edge features and extensive operability, it's easy to see why. Although you can make some adjustments to it to suit your PC, and its functionality depends heavily on AppleOS, so its functionality will be limited. How do I connect AppleVisionPro to my computer? 1. Verify system requirements You need the latest version of Windows 11 (Custom PCs and Surface devices are not supported) Support 64-bit 2GHZ or faster fast processor High-performance GPU, most

Shazam app not working in iPhone: Fix Shazam app not working in iPhone: Fix Jun 08, 2024 pm 12:36 PM

Having issues with the Shazam app on iPhone? Shazam helps you find songs by listening to them. However, if Shazam isn't working properly or doesn't recognize the song, you'll have to troubleshoot it manually. Repairing the Shazam app won't take long. So, without wasting any more time, follow the steps below to resolve issues with Shazam app. Fix 1 – Disable Bold Text Feature Bold text on iPhone may be the reason why Shazam is not working properly. Step 1 – You can only do this from your iPhone settings. So, open it. Step 2 – Next, open the “Display & Brightness” settings there. Step 3 – If you find that “Bold Text” is enabled

Four recommended AI-assisted programming tools Four recommended AI-assisted programming tools Apr 22, 2024 pm 05:34 PM

This AI-assisted programming tool has unearthed a large number of useful AI-assisted programming tools in this stage of rapid AI development. AI-assisted programming tools can improve development efficiency, improve code quality, and reduce bug rates. They are important assistants in the modern software development process. Today Dayao will share with you 4 AI-assisted programming tools (and all support C# language). I hope it will be helpful to everyone. https://github.com/YSGStudyHards/DotNetGuide1.GitHubCopilotGitHubCopilot is an AI coding assistant that helps you write code faster and with less effort, so you can focus more on problem solving and collaboration. Git

Learn how to develop mobile applications using Go language Learn how to develop mobile applications using Go language Mar 28, 2024 pm 10:00 PM

Go language development mobile application tutorial As the mobile application market continues to boom, more and more developers are beginning to explore how to use Go language to develop mobile applications. As a simple and efficient programming language, Go language has also shown strong potential in mobile application development. This article will introduce in detail how to use Go language to develop mobile applications, and attach specific code examples to help readers get started quickly and start developing their own mobile applications. 1. Preparation Before starting, we need to prepare the development environment and tools. head

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Apr 07, 2024 am 09:10 AM

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A

How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 Mar 22, 2024 pm 04:40 PM

While studying in high school, some students take very clear and accurate notes, taking more notes than others in the same class. For some, note-taking is a hobby, while for others, it is a necessity when they easily forget small information about anything important. Microsoft's NTFS application is particularly useful for students who wish to save important notes beyond regular lectures. In this article, we will describe the installation of Ubuntu applications on Ubuntu24. Updating the Ubuntu System Before installing the Ubuntu installer, on Ubuntu24 we need to ensure that the newly configured system has been updated. We can use the most famous "a" in Ubuntu system

Understanding VSCode: What is this tool used for? Understanding VSCode: What is this tool used for? Mar 25, 2024 pm 03:06 PM

"Understanding VSCode: What is this tool used for?" 》As a programmer, whether you are a beginner or an experienced developer, you cannot do without the use of code editing tools. Among many editing tools, Visual Studio Code (VSCode for short) is very popular among developers as an open source, lightweight, and powerful code editor. So, what exactly is VSCode used for? This article will delve into the functions and uses of VSCode and provide specific code examples to help readers

Introduction to PHP interfaces and how to define them Introduction to PHP interfaces and how to define them Mar 23, 2024 am 09:00 AM

Introduction to PHP interface and how it is defined. PHP is an open source scripting language widely used in Web development. It is flexible, simple, and powerful. In PHP, an interface is a tool that defines common methods between multiple classes, achieving polymorphism and making code more flexible and reusable. This article will introduce the concept of PHP interfaces and how to define them, and provide specific code examples to demonstrate their usage. 1. PHP interface concept Interface plays an important role in object-oriented programming, defining the class application

See all articles