doctrine.xml 4.21 KB
Newer Older
1 2 3 4
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"

[
5
<!ENTITY chap1 SYSTEM "intro.xml">
6
<!ENTITY chap2 SYSTEM "conn-mgt.xml">
7 8 9 10 11 12
]>

<book id="doctrinebook">

  <bookinfo>
    <title>Doctrine Documentation</title>
13 14 15
    <author>
      <firstname>Konsta</firstname>
      <surname>Vesterinen</surname>
pookey's avatar
pookey committed
16
      <authorblurb>The creator and lead developer.</authorblurb>
17
    </author>
18 19
    <author>
      <firstname>Ian</firstname>
pookey's avatar
pookey committed
20
      <othername>P.</othername>
21 22
      <surname>Christian</surname>
      <email>pookey@pookey.co.uk</email>
pookey's avatar
pookey committed
23
      <authorblurb>Junior developer and documentation maintainer.</authorblurb>
24 25 26 27 28 29 30 31 32 33 34 35 36 37
    </author>
    <copyright>
      <holder>Doctrine Project</holder>
      <year>2007</year>
    </copyright>
    <legalnotice id="legalnotice">
      <para>
        The contents of this document are licensed under the Creative Commons
        <ulink url="http://creativecommons.org/licenses/by-sa/2.0/">Attribution-ShareAlike License</ulink>.
      </para>
    </legalnotice>

    <abstract>
      <para>
38 39 40 41
        Documentation for the PHP Doctrine project.
      </para>
      <para>
        This document was generated <?dbtimestamp format="Y-m-d H:M:S"?>.
42 43 44
      </para>
    </abstract>
  </bookinfo>
45

46 47
  &chap1;
  &chap2;
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

  <chapter id="object-relational-mapping">
  <title>Object Relational Mapping</title>
  </chapter>

  <chapter id="working-with-objects">
  <title>Working With Objects</title>
  </chapter>

  <chapter id="configuration">
  <title>Configuration</title>
  </chapter>

  <chapter id="advanced-components">
  <title>Advanced Components</title>
  </chapter>

  <chapter id="dql">
  <title>DQL (Doctrine Query Lanaguage)</title>
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
  <sect1 id="dql-intro">
    <title>Introduction</title>
    <para>
    Doctrine Query Language(DQL) is an Object Query Language created for helping users in complex object retrieval.
    </para>
    <para>
    You should always consider using DQL(or raw SQL) when retrieving relational data efficiently (eg. when fetching users and their phonenumbers).
    </para>
    <para>
    When compared to using raw SQL, DQL has several benefits:
    </para>

    <itemizedlist>
      <listitem><para>From the start it has been designed to retrieve records(objects) not result set rows.</para></listitem>
      <listitem><para>DQL understands relations so you don't have to type manually sql joins and join conditions.</para></listitem>
      <listitem><para>DQL is portable on different databases</para></listitem>
      <listitem><para>DQL has some very complex built-in algorithms like (the record limit algorithm) which can help developer to efficiently retrieve objects.</para></listitem>
      <listitem><para>It supports some functions that can save time when dealing with one-to-many, many-to-many relational data with conditional fetching.</para></listitem>
    </itemizedlist>

    <para>
      If the power of DQL isn't enough, you should consider using the rawSql API for object population.
    </para>

91
    <programlisting role="php"><![CDATA[
92 93 94 95 96 97 98 99 100
<?php 
  // DO NOT USE THE FOLLOWING CODE 
  // (using many sql queries for object population):

  $users = $conn->getTable('User')->findAll();
  foreach($users as $user) {
    print $user->name."\n";
    foreach($user->Phonenumber as $phonenumber) {
        print $phonenumber."\n";
101
    }
102 103 104 105
  }

  // same thing implemented much more efficiently: 
  // (using only one sql query for object population)
106

107 108 109 110 111 112 113
  $users = $conn->query("FROM User.Phonenumber");
  foreach($users as $user) {
    print $user->name."\n";
    foreach($user->Phonenumber as $phonenumber) {
        print $phonenumber."\n";
    }
  }
114
?>]]></programlisting>
115
  </sect1>
116

117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
  </chapter>

  <chapter id="native-sql">
  <title>Native SQL</title>
  </chapter>

  <chapter id="transactions">
  <title>Transactions</title>
  </chapter>

  <chapter id="caching">
  <title>Caching</title>
  </chapter>

  <chapter id="database-abstraction">
  <title>Database Abstraction</title>
  </chapter>

  <chapter id="technology">
  <title>Technology</title>
  </chapter>

  <chapter id="real-world-examples">
  <title>Real World Examples</title>
  </chapter>

  <chapter id="coding-standards">
  <title>Coding Standards</title>
  </chapter>

147
</book>