@@ -44,21 +44,21 @@ Configuring the Database
44
44
45
45
Before you really begin, you'll need to configure your database connection
46
46
information. By convention, this information is usually configured in an
47
- ``app/config/parameters.ini `` file:
47
+ ``app/config/parameters.yml `` file:
48
48
49
- .. code-block :: ini
49
+ .. code-block :: yaml
50
50
51
- ; app/config/parameters.ini
52
- [ parameters]
53
- database_driver = pdo_mysql
54
- database_host = localhost
55
- database_name = test_project
56
- database_user = root
57
- database_password = password
51
+ # app/config/parameters.yml
52
+ parameters :
53
+ database_driver : pdo_mysql
54
+ database_host : localhost
55
+ database_name : test_project
56
+ database_user : root
57
+ database_password : password
58
58
59
59
.. note ::
60
60
61
- Defining the configuration via ``parameters.ini `` is just a convention.
61
+ Defining the configuration via ``parameters.yml `` is just a convention.
62
62
The parameters defined in that file are referenced by the main configuration
63
63
file when setting up Doctrine:
64
64
@@ -377,7 +377,7 @@ of the bundle:
377
377
$product->setPrice('19.99');
378
378
$product->setDescription('Lorem ipsum dolor');
379
379
380
- $em = $this->getDoctrine()->getEntityManager ();
380
+ $em = $this->getDoctrine()->getManager ();
381
381
$em->persist($product);
382
382
$em->flush();
383
383
@@ -515,7 +515,7 @@ you have a route that maps a product id to an update action in a controller::
515
515
516
516
public function updateAction($id)
517
517
{
518
- $em = $this->getDoctrine()->getEntityManager ();
518
+ $em = $this->getDoctrine()->getManager ();
519
519
$product = $em->getRepository('AcmeStoreBundle:Product')->find($id);
520
520
521
521
if (!$product) {
@@ -579,7 +579,7 @@ Imagine that you want to query for products, but only return products that
579
579
cost more than ``19.99 ``, ordered from cheapest to most expensive. From inside
580
580
a controller, do the following::
581
581
582
- $em = $this->getDoctrine()->getEntityManager ();
582
+ $em = $this->getDoctrine()->getManager ();
583
583
$query = $em->createQuery(
584
584
'SELECT p FROM AcmeStoreBundle:Product p WHERE p.price > :price ORDER BY p.price ASC'
585
585
)->setParameter('price', '19.99');
@@ -741,20 +741,20 @@ ordered alphabetically.
741
741
{
742
742
public function findAllOrderedByName()
743
743
{
744
- return $this->getEntityManager ()
744
+ return $this->getManager ()
745
745
->createQuery('SELECT p FROM AcmeStoreBundle:Product p ORDER BY p.name ASC')
746
746
->getResult();
747
747
}
748
748
}
749
749
750
750
.. tip ::
751
751
752
- The entity manager can be accessed via ``$this->getEntityManager () ``
752
+ The entity manager can be accessed via ``$this->getManager () ``
753
753
from inside the repository.
754
754
755
755
You can use this new method just like the default finder methods of the repository::
756
756
757
- $em = $this->getDoctrine()->getEntityManager ();
757
+ $em = $this->getDoctrine()->getManager ();
758
758
$products = $em->getRepository('AcmeStoreBundle:Product')
759
759
->findAllOrderedByName();
760
760
@@ -946,7 +946,7 @@ Now, let's see the code in action. Imagine you're inside a controller::
946
946
// relate this product to the category
947
947
$product->setCategory($category);
948
948
949
- $em = $this->getDoctrine()->getEntityManager ();
949
+ $em = $this->getDoctrine()->getManager ();
950
950
$em->persist($category);
951
951
$em->persist($product);
952
952
$em->flush();
@@ -1061,7 +1061,7 @@ following method to the ``ProductRepository`` class::
1061
1061
1062
1062
public function findOneByIdJoinedToCategory($id)
1063
1063
{
1064
- $query = $this->getEntityManager ()
1064
+ $query = $this->getManager ()
1065
1065
->createQuery('
1066
1066
SELECT p, c FROM AcmeStoreBundle:Product p
1067
1067
JOIN p.category c
@@ -1377,14 +1377,14 @@ For more information about Doctrine, see the *Doctrine* section of the
1377
1377
1378
1378
.. _`Doctrine` : http://www.doctrine-project.org/
1379
1379
.. _`MongoDB` : http://www.mongodb.org/
1380
- .. _`Basic Mapping Documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1 /reference/basic-mapping.html
1381
- .. _`Query Builder` : http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1 /reference/query-builder.html
1382
- .. _`Doctrine Query Language` : http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1 /reference/dql-doctrine-query-language.html
1383
- .. _`Association Mapping Documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1 /reference/association-mapping.html
1380
+ .. _`Basic Mapping Documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest /reference/basic-mapping.html
1381
+ .. _`Query Builder` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest /reference/query-builder.html
1382
+ .. _`Doctrine Query Language` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest /reference/dql-doctrine-query-language.html
1383
+ .. _`Association Mapping Documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest /reference/association-mapping.html
1384
1384
.. _`DateTime` : http://php.net/manual/en/class.datetime.php
1385
- .. _`Mapping Types Documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1 /reference/basic-mapping.html#doctrine-mapping-types
1386
- .. _`Property Mapping documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1 /reference/basic-mapping.html#property-mapping
1387
- .. _`Lifecycle Events documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1 /reference/events.html#lifecycle-events
1388
- .. _`Reserved SQL keywords documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1 /reference/basic-mapping.html#quoting-reserved-words
1389
- .. _`Persistent classes` : http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1 /reference/basic-mapping.html#persistent-classes
1390
- .. _`Property Mapping` : http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1 /reference/basic-mapping.html#property-mapping
1385
+ .. _`Mapping Types Documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest /reference/basic-mapping.html#doctrine-mapping-types
1386
+ .. _`Property Mapping documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest /reference/basic-mapping.html#property-mapping
1387
+ .. _`Lifecycle Events documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest /reference/events.html#lifecycle-events
1388
+ .. _`Reserved SQL keywords documentation` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest /reference/basic-mapping.html#quoting-reserved-words
1389
+ .. _`Persistent classes` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest /reference/basic-mapping.html#persistent-classes
1390
+ .. _`Property Mapping` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest /reference/basic-mapping.html#property-mapping
0 commit comments