Skip to content

Commit 8b3605a

Browse files
committed
Fixed code examples in book/doctrine
1 parent c354c00 commit 8b3605a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

book/doctrine.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ information. By convention, this information is usually configured in an
4848

4949
.. code-block:: ini
5050
51-
;app/config/parameters.ini
51+
; app/config/parameters.ini
5252
[parameters]
5353
database_driver = pdo_mysql
5454
database_host = localhost
@@ -64,6 +64,7 @@ information. By convention, this information is usually configured in an
6464

6565
.. code-block:: yaml
6666
67+
# app/config/config.yml
6768
doctrine:
6869
dbal:
6970
driver: %database_driver%
@@ -366,9 +367,10 @@ of the bundle:
366367
:linenos:
367368
368369
// src/Acme/StoreBundle/Controller/DefaultController.php
370+
371+
// ...
369372
use Acme\StoreBundle\Entity\Product;
370373
use Symfony\Component\HttpFoundation\Response;
371-
// ...
372374
373375
public function createAction()
374376
{
@@ -444,7 +446,7 @@ on its ``id`` value::
444446
throw $this->createNotFoundException('No product found for id '.$id);
445447
}
446448

447-
// do something, like pass the $product object into a template
449+
// ... do something, like pass the $product object into a template
448450
}
449451

450452
When you query for a particular type of object, you always use what's known
@@ -605,7 +607,7 @@ for just one object, you can use the ``getSingleResult()`` method instead::
605607
returned (if you're querying on something that could feasibly return
606608
more than one result)::
607609
608-
$query = $em->createQuery('SELECT ....')
610+
$query = $em->createQuery('SELECT ...')
609611
->setMaxResults(1);
610612
611613
try {
@@ -710,6 +712,7 @@ To do this, add the name of the repository class to your mapping definition.
710712
.. code-block:: xml
711713
712714
<!-- src/Acme/StoreBundle/Resources/config/doctrine/Product.orm.xml -->
715+
713716
<!-- ... -->
714717
<doctrine-mapping>
715718
@@ -792,6 +795,7 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
792795
.. code-block:: php-annotations
793796
794797
// src/Acme/StoreBundle/Entity/Category.php
798+
795799
// ...
796800
use Doctrine\Common\Collections\ArrayCollection;
797801
@@ -852,6 +856,7 @@ object, you'll want to add a ``$category`` property to the ``Product`` class:
852856
.. code-block:: php-annotations
853857
854858
// src/Acme/StoreBundle/Entity/Product.php
859+
855860
// ...
856861
857862
class Product
@@ -928,10 +933,10 @@ Saving Related Entities
928933
Now, let's see the code in action. Imagine you're inside a controller::
929934

930935
// ...
936+
931937
use Acme\StoreBundle\Entity\Category;
932938
use Acme\StoreBundle\Entity\Product;
933939
use Symfony\Component\HttpFoundation\Response;
934-
// ...
935940

936941
class DefaultController extends Controller
937942
{
@@ -1058,7 +1063,6 @@ can avoid the second query by issuing a join in the original query. Add the
10581063
following method to the ``ProductRepository`` class::
10591064

10601065
// src/Acme/StoreBundle/Repository/ProductRepository.php
1061-
10621066
public function findOneByIdJoinedToCategory($id)
10631067
{
10641068
$query = $this->getEntityManager()
@@ -1162,6 +1166,7 @@ the current date, only when the entity is first persisted (i.e. inserted):
11621166
.. code-block:: xml
11631167
11641168
<!-- src/Acme/StoreBundle/Resources/config/doctrine/Product.orm.xml -->
1169+
11651170
<!-- ... -->
11661171
<doctrine-mapping>
11671172

0 commit comments

Comments
 (0)