adding an example contianing a list and a code block
This commit is contained in:
parent
a1bfac1135
commit
cfa0351d2b
@ -9,15 +9,15 @@
|
|||||||
|
|
||||||
<bookinfo>
|
<bookinfo>
|
||||||
<title>Doctrine Documentation</title>
|
<title>Doctrine Documentation</title>
|
||||||
|
<author>
|
||||||
|
<firstname>Konsta</firstname>
|
||||||
|
<surname>Vesterinen</surname>
|
||||||
|
</author>
|
||||||
<author>
|
<author>
|
||||||
<firstname>Ian</firstname>
|
<firstname>Ian</firstname>
|
||||||
<surname>Christian</surname>
|
<surname>Christian</surname>
|
||||||
<email>pookey@pookey.co.uk</email>
|
<email>pookey@pookey.co.uk</email>
|
||||||
</author>
|
</author>
|
||||||
<author>
|
|
||||||
<firstname>Konsta</firstname>
|
|
||||||
<surname>Vesterinen</surname>
|
|
||||||
</author>
|
|
||||||
<copyright>
|
<copyright>
|
||||||
<holder>Doctrine Project</holder>
|
<holder>Doctrine Project</holder>
|
||||||
<year>2007</year>
|
<year>2007</year>
|
||||||
@ -31,27 +31,30 @@
|
|||||||
|
|
||||||
<abstract>
|
<abstract>
|
||||||
<para>
|
<para>
|
||||||
Documentation for the PHP Doctrine project
|
Documentation for the PHP Doctrine project.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
This document was generated <?dbtimestamp format="Y-m-d H:M:S"?>.
|
||||||
</para>
|
</para>
|
||||||
</abstract>
|
</abstract>
|
||||||
</bookinfo>
|
</bookinfo>
|
||||||
|
|
||||||
<chapter id="introduction">
|
<chapter id="introduction">
|
||||||
<title>Introduction</title>
|
<title>Introduction</title>
|
||||||
<para>
|
<sect1 id="about-doctrine">
|
||||||
Doctrine is a Object Relational Mapping and database abstraction
|
<title>About Doctrine</title>
|
||||||
framework for PHP. The DBAL part of Doctrine derives from MDB2. The key
|
<para>
|
||||||
idea was to provide very intuitive and easy-to-use persistency solution
|
Doctrine is a Object Relational Mapping and database abstraction
|
||||||
(eg. RoR ActiveRecord) with all the advanced features from the more
|
framework for PHP. The DBAL part of Doctrine derives from MDB2. The key
|
||||||
heavy-weight solutions (eg. Hibernate).
|
idea was to provide very intuitive and easy-to-use persistency solution
|
||||||
</para>
|
(eg. RoR ActiveRecord) with all the advanced features from the more
|
||||||
<para>
|
heavy-weight solutions (eg. Hibernate).
|
||||||
Doctrine Query Language implements EJB 3 OQL specificiation and expands
|
</para>
|
||||||
it a bit further (it has special LIMIT and OFFSET clauses).
|
<para>
|
||||||
</para>
|
Doctrine Query Language implements EJB 3 OQL specificiation and expands
|
||||||
<para>
|
it a bit further (it has special LIMIT and OFFSET clauses).
|
||||||
|
</para>
|
||||||
</para>
|
</sect1>
|
||||||
|
|
||||||
<sect1 id="requirements">
|
<sect1 id="requirements">
|
||||||
<title>Requirements</title>
|
<title>Requirements</title>
|
||||||
@ -144,6 +147,59 @@
|
|||||||
|
|
||||||
<chapter id="dql">
|
<chapter id="dql">
|
||||||
<title>DQL (Doctrine Query Lanaguage)</title>
|
<title>DQL (Doctrine Query Lanaguage)</title>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
<?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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// same thing implemented much more efficiently:
|
||||||
|
// (using only one sql query for object population)
|
||||||
|
|
||||||
|
$users = $conn->query("FROM User.Phonenumber");
|
||||||
|
foreach($users as $user) {
|
||||||
|
print $user->name."\n";
|
||||||
|
foreach($user->Phonenumber as $phonenumber) {
|
||||||
|
print $phonenumber."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
</sect1>
|
||||||
|
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
||||||
<chapter id="native-sql">
|
<chapter id="native-sql">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user