18.10.2016 Views

Drupal 7 Module Development

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Database Access<br />

Although <strong>Drupal</strong> 7 has made major leaps forward in terms of the flexibility of its<br />

data storage in practice the vast majority of <strong>Drupal</strong> sites still rely on an SQL database<br />

for both their primary data and for most of the configuration. In the past <strong>Drupal</strong> has<br />

relied on a very thin database layer that provided only limited abstraction beyond<br />

PHP's native support for the MySQL and PostgreSQL databases, which was a serious<br />

limitation for complex or traffic-heavy sites.<br />

<strong>Drupal</strong> 7, however, features a brand new database layer rewritten from the<br />

ground up to provide a wide range of robust features in the areas of security,<br />

scalability, and developer flexibility. Known somewhat tongue-in-cheek as<br />

"Databases: The Next Generation" or "DBTNG" during development, it offers<br />

support for many advanced SQL features as well as vastly improved portability<br />

between the leading SQL databases on the market. In fact, <strong>Drupal</strong> 7 now ships with<br />

support for the three leading open source databases (MySQL and variants such as<br />

Maria DB, PostgreSQL, and SQLite) out-of-the-box and as of this writing add-on<br />

drivers are available for both, Microsoft SQL Server and Oracle.<br />

The database API is well documented, but this section will provide an overview of<br />

the major features of the database API and how to use them to ensure fast, robust<br />

code. We'll assume an existing knowledge of SQL. For more detailed information see<br />

http://drupal.org/developing/api/database and http://api.drupal.org/<br />

api/group/database/7.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!