10.04.2018 Views

Doctrine_manual-1-2-en

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

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

Chapter 20: Database Abstraction Layer 292<br />

Chapter 20<br />

Database Abstraction Layer<br />

The <strong>Doctrine</strong> Database Abstraction Layer is the underlying framework that the ORM uses to<br />

communicate with the database and s<strong>en</strong>d the appropriate SQL dep<strong>en</strong>ding on which database<br />

type you are using. It also has the ability to query the database for information like what table<br />

a database has or what fields a table has. This is how <strong>Doctrine</strong> is able to g<strong>en</strong>erate your<br />

models from existing databases so easily.<br />

This layer can be used indep<strong>en</strong>d<strong>en</strong>tly of the ORM. This might be of use for example if you<br />

have an existing application that uses PDO directly and you want to port it to use the <strong>Doctrine</strong><br />

Connections and DBAL. At a later phase you could begin to use the ORM for new things and<br />

rewrite old pieces to use the ORM.<br />

The DBAL is composed of a few differ<strong>en</strong>t modules. In this chapter we will discuss the<br />

differ<strong>en</strong>t modules and what their jobs are.<br />

Export<br />

The Export module provides methods for managing database structure. The methods can be<br />

grouped based on their responsibility: create, edit (alter or update), list or delete (drop)<br />

database elem<strong>en</strong>ts. The following docum<strong>en</strong>t lists the available methods, providing examples<br />

of their use.<br />

Introduction<br />

Every schema altering method in the Export module has an equival<strong>en</strong>t which returns the SQL<br />

that is used for the altering operation. For example createTable() executes the query /<br />

queries returned by createTableSql().<br />

In this chapter the following tables will be created, altered and finally dropped, in a database<br />

named ev<strong>en</strong>ts_db:<br />

ev<strong>en</strong>ts<br />

Name Type Primary Auto Increm<strong>en</strong>t<br />

id integer true true<br />

name string(255) false false<br />

datetime timestamp false false<br />

people<br />

Name Type<br />

Primary Auto Increm<strong>en</strong>t<br />

----------------- Brought to you by

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

Saved successfully!

Ooh no, something went wrong!