@@ -48,7 +48,7 @@ information. By convention, this information is usually configured in an
48
48
49
49
.. code-block :: ini
50
50
51
- ; app/config/parameters.ini
51
+ ; app/config/parameters.ini
52
52
[parameters]
53
53
database_driver = pdo_mysql
54
54
database_host = localhost
@@ -64,6 +64,7 @@ information. By convention, this information is usually configured in an
64
64
65
65
.. code-block :: yaml
66
66
67
+ # app/config/config.yml
67
68
doctrine :
68
69
dbal :
69
70
driver : %database_driver%
@@ -366,9 +367,10 @@ of the bundle:
366
367
:linenos:
367
368
368
369
// src/Acme/StoreBundle/Controller/DefaultController.php
370
+
371
+ // ...
369
372
use Acme\StoreBundle\Entity\Product;
370
373
use Symfony\Component\HttpFoundation\Response;
371
- // ...
372
374
373
375
public function createAction()
374
376
{
@@ -444,7 +446,7 @@ on its ``id`` value::
444
446
throw $this->createNotFoundException('No product found for id '.$id);
445
447
}
446
448
447
- // do something, like pass the $product object into a template
449
+ // ... do something, like pass the $product object into a template
448
450
}
449
451
450
452
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::
605
607
returned (if you're querying on something that could feasibly return
606
608
more than one result)::
607
609
608
- $query = $em->createQuery('SELECT .... ')
610
+ $query = $em->createQuery('SELECT ...')
609
611
->setMaxResults(1);
610
612
611
613
try {
@@ -710,6 +712,7 @@ To do this, add the name of the repository class to your mapping definition.
710
712
.. code-block :: xml
711
713
712
714
<!-- src/Acme/StoreBundle/Resources/config/doctrine/Product.orm.xml -->
715
+
713
716
<!-- ... -->
714
717
<doctrine-mapping >
715
718
@@ -792,6 +795,7 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
792
795
.. code-block :: php-annotations
793
796
794
797
// src/Acme/StoreBundle/Entity/Category.php
798
+
795
799
// ...
796
800
use Doctrine\Common\Collections\ArrayCollection;
797
801
@@ -852,6 +856,7 @@ object, you'll want to add a ``$category`` property to the ``Product`` class:
852
856
.. code-block :: php-annotations
853
857
854
858
// src/Acme/StoreBundle/Entity/Product.php
859
+
855
860
// ...
856
861
857
862
class Product
@@ -928,10 +933,10 @@ Saving Related Entities
928
933
Now, let's see the code in action. Imagine you're inside a controller::
929
934
930
935
// ...
936
+
931
937
use Acme\StoreBundle\Entity\Category;
932
938
use Acme\StoreBundle\Entity\Product;
933
939
use Symfony\Component\HttpFoundation\Response;
934
- // ...
935
940
936
941
class DefaultController extends Controller
937
942
{
@@ -1058,7 +1063,6 @@ can avoid the second query by issuing a join in the original query. Add the
1058
1063
following method to the ``ProductRepository `` class::
1059
1064
1060
1065
// src/Acme/StoreBundle/Repository/ProductRepository.php
1061
-
1062
1066
public function findOneByIdJoinedToCategory($id)
1063
1067
{
1064
1068
$query = $this->getEntityManager()
@@ -1162,6 +1166,7 @@ the current date, only when the entity is first persisted (i.e. inserted):
1162
1166
.. code-block :: xml
1163
1167
1164
1168
<!-- src/Acme/StoreBundle/Resources/config/doctrine/Product.orm.xml -->
1169
+
1165
1170
<!-- ... -->
1166
1171
<doctrine-mapping >
1167
1172
0 commit comments