一次編寫,隨處運行

關於 php(做為現在的主流開發語言) 的數據庫 API 對於不同的數據庫有不同的函數,一直以來就有人嘗試使用 php(做為現在的主流開發語言) 的面向對象的功能進行一些封裝。其中有比較著名的ADODB,php(做為現在的主流開發語言)LIB。後來舉世矚目的 PEAR 項目中的 PEAR DB 更是其中的佼佼者。這些用面向對象對數據庫 API 進行的封裝的包一般稱為數據庫抽象層。

本文介紹的是 PEAR 中對 PEAR DB 進行融合 Metabase 庫的一些優秀功能之後產生的註重效率,而且簡單易用,功能非常強大的 MDB 的一個非常好的介紹。作者就是 MDB 的主創人員。

想獲得我最近關註的 php(做為現在的主流開發語言)/PEAR 的最新原創和譯文,請訪問我的主頁

Write once – run anywhere
一次編寫——隨處運行

PEAR MDB Database Abstraction Layer
PEAR MDB 數據庫抽象層

作者:Lukas Smith
譯者:taowen

While this is a Java marketing phrase it is also a key feature of php(做為現在的主流開發語言). Many business models depend on operation system independence to ensure that products can be sold to a wide range of customers. So why lock yourself in with a specific database vendor? Database abstraction layers allow you to develop your application independent of a database. But often they eat more performance than you are willing to give or they do not abstract enough to eliminate all database specific code.
這是Java的一句行銷口號,但是它同時也是php(做為現在的主流開發語言)的關鍵特性之一。許多商業模型依賴於操作系統無關性來保證產品能夠銷售給廣泛的客戶群體。因而,為什麼要把你自己綁在某種數據庫廠商的身上呢?數據庫抽象層使得你能夠與數據庫獨立的開發你的應用程序。但是,通常情況下它們對性能的影響超過瞭你所希望的,要麼他們並不足夠抽象以消除所有和特定數據庫相關的代碼。

What will this article teach me?
這篇文章將教給我什麼?

This article will give a good introduction to the database abstraction package PEAR MDB. The focus will be explaining the more advanced features of MDB like data type abstraction and the xml(標準化越來越近瞭) based schema management that go beyond what other similar packages offer. A basic level of understanding of php(做為現在的主流開發語言) and SQL is recommended.
這篇文章將對數據庫抽象包 PEAR MDB 有一個很好的介紹。文章的焦點將是對 MDB 超越類似包所提供的更先進的特性,例如數據類型抽象和基於 xml(標準化越來越近瞭) 的 schema 管理。對 php(做為現在的主流開發語言) 和 SQL 的基本理解是推薦的。

Why another database class?
為什麼另外再要一個數據庫類?

Often, web projects are added to existing IT infrastructures, where the client already made a choice of what RDBMS (relational database management system) to work with. Even if that is not the case different budgets might affect what database you chose for deployment. Finally, you as the developer simply might prefer not to lock yourself in with a specific vendor. So far this meant to keep multiple versions for each supported database or giving up more performance and ease of use than necessary: Enter PEAR MDB.
通常, web 工程在客戶已經確定瞭要使用那種 RDBMS (關系型數據庫管理系統)之後被添加給已經存在的 IT 基礎結構。即使那並不是因為不同的預算可能影響的你選擇何種數據用於部署的情況。最終,你作為開發者可能簡單的偏好於不把自己綁在某個廠商身上。自此,意味著給每個支持的數據保持版本或者犧牲更多性能但是獲得多於必須的易用性:走入 PEAR MDB 吧。

MDB is a database abstraction layer that aims to make writing RDBMS independent php(做為現在的主流開發語言) application development a straightforward process. Most other so called database abstraction layers for php(做為現在的主流開發語言) only provide a common API for all supported databases and only very limited abstraction (mostly only for sequences). MDB on the other hand can be used to abstract all data being send and received from the database. Even database schemas can be defined in a RDBMS independent format. But it does this while retaining a high level of performance and ease of use. This was achieved by closely examining two popular database abstraction layers, PEAR DB and Metabase, and merging them. But during the merging the opportunity was also used to clean up their merged APIs as well as any performance hindering design patterns.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *