Skip to content

Commit 6c083c8

Browse files
committed
Merge pull request symfony#2443 from WouterJ/facelift_propel
[symfony#2381] Facelifted book/propel
2 parents 6e08e18 + be2e44a commit 6c083c8

File tree

1 file changed

+37
-24
lines changed

1 file changed

+37
-24
lines changed

book/propel.rst

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Databases and Propel
77
One of the most common and challenging tasks for any application
88
involves persisting and reading information to and from a database. Symfony2
99
does not come integrated with any ORMs but the Propel integration is easy.
10-
To get started, read `Working With Symfony2`_.
10+
To install Propel, read `Working With Symfony2`_ on the Propel documentation.
1111

1212
A Simple Example: A Product
1313
---------------------------
@@ -28,7 +28,7 @@ Configuring the Database
2828
~~~~~~~~~~~~~~~~~~~~~~~~
2929

3030
Before you can start, you'll need to configure your database connection
31-
information. By convention, this information is usually configured in an
31+
information. By convention, this information is usually configured in an
3232
``app/config/parameters.ini`` file:
3333

3434
.. code-block:: ini
@@ -42,20 +42,17 @@ information. By convention, this information is usually configured in an
4242
database_password = password
4343
database_charset = UTF8
4444
45-
.. note::
46-
47-
Defining the configuration via ``parameters.ini`` is just a convention. The
48-
parameters defined in that file are referenced by the main configuration
49-
file when setting up Propel:
45+
These parameters defined in ``parameters.ini`` can now be included in the
46+
configuration file (``config.yml``):
5047

51-
.. code-block:: yaml
48+
.. code-block:: yaml
5249
53-
propel:
54-
dbal:
55-
driver: "%database_driver%"
56-
user: "%database_user%"
57-
password: "%database_password%"
58-
dsn: "%database_driver%:host=%database_host%;dbname=%database_name%;charset=%database_charset%"
50+
propel:
51+
dbal:
52+
driver: "%database_driver%"
53+
user: "%database_user%"
54+
password: "%database_password%"
55+
dsn: "%database_driver%:host=%database_host%;dbname=%database_name%;charset=%database_charset%"
5956
6057
Now that Propel knows about your database, Symfony2 can create the database for
6158
you:
@@ -88,12 +85,28 @@ of your ``AcmeStoreBundle``:
8885
.. code-block:: xml
8986
9087
<?xml version="1.0" encoding="UTF-8"?>
91-
<database name="default" namespace="Acme\StoreBundle\Model" defaultIdMethod="native">
88+
<database name="default"
89+
namespace="Acme\StoreBundle\Model"
90+
defaultIdMethod="native"
91+
>
9292
<table name="product">
93-
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
94-
<column name="name" type="varchar" primaryString="true" size="100" />
95-
<column name="price" type="decimal" />
96-
<column name="description" type="longvarchar" />
93+
<column name="id"
94+
type="integer"
95+
required="true"
96+
primaryKey="true"
97+
autoIncrement="true"
98+
/>
99+
<column name="name"
100+
type="varchar"
101+
primaryString="true"
102+
size="100"
103+
/>
104+
<column name="price"
105+
type="decimal"
106+
/>
107+
<column name="description"
108+
type="longvarchar"
109+
/>
97110
</table>
98111
</database>
99112
@@ -217,15 +230,15 @@ have a route that maps a product id to an update action in a controller::
217230

218231
Updating an object involves just three steps:
219232

220-
#. fetching the object from Propel;
221-
#. modifying the object;
222-
#. saving it.
233+
#. fetching the object from Propel (line 6 - 13);
234+
#. modifying the object (line 15);
235+
#. saving it (line 16).
223236

224237
Deleting an Object
225238
~~~~~~~~~~~~~~~~~~
226239

227-
Deleting an object is very similar, but requires a call to the ``delete()``
228-
method on the object::
240+
Deleting an object is very similar to updating, but requires a call to the
241+
``delete()`` method on the object::
229242

230243
$product->delete();
231244

0 commit comments

Comments
 (0)