Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 52 lines (39 sloc) 1.783 kb
022781cc »
2010-11-01 Convert Documentation from Markdown to RST.
1 Platforms
2 =========
3
4 Platforms abstract query generation and the subtle differences of
5 the supported database vendors. In most cases you don't need to
6 interact with the ``Doctrine\DBAL\Platforms`` package a lot, but
7 there might be certain cases when you are programming database
8 independent where you want to access the platform to generate
9 queries for you.
10
11 The platform can be accessed from any ``Doctrine\DBAL\Connection``
12 instance by calling the ``getDatabasePlatform()`` method.
13
14 ::
15
16 <?php
17 $platform = $conn->getDatabasePlatform();
18
19 Each database driver has a platform associated with it by default.
20 Several drivers also share the same platform, for example PDO\_OCI
21 and OCI8 share the ``OraclePlatform``.
22
23 If you want to overwrite parts of your platform you can do so when
24 creating a connection. There is a ``platform`` option you can pass
25 an instance of the platform you want the connection to use:
26
27 ::
28
29 <?php
30 $myPlatform = new MyPlatform();
31 $options = array(
32 'driver' => 'pdo_sqlite',
33 'path' => 'database.sqlite',
34 'platform' => $myPlatform
35 );
36 $conn = DriverManager::getConnection($options);
37
38 This way you can optimize your schema or generated SQL code with
39 features that might not be portable for instance, however are
40 required for your special needs. This can include using triggers or
41 views to simulate features or adding behaviour to existing SQL
42 functions.
43
44 Platforms are also responsible to know which database type
45 translates to which PHP Type. This is a very tricky issue across
46 all the different database vendors, for example MySQL BIGINT and
47 Oracle NUMBER should be handled as integer. Doctrine 2 offers a
48 powerful way to abstract the database to php and back conversion,
49 which is described in the next section.
50
51
Something went wrong with that request. Please try again.