From 754ebc052ef73e6484dde68e891bf4fba14fafe7 Mon Sep 17 00:00:00 2001 From: Joel Clermont Date: Thu, 27 Jan 2011 21:02:56 +0800 Subject: [PATCH 1/9] DDC-823 - Fix minor grammar and punctuation mistakes --- en/tutorials/getting-started-xml-edition.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/en/tutorials/getting-started-xml-edition.rst b/en/tutorials/getting-started-xml-edition.rst index 863f5f603..430a6756a 100644 --- a/en/tutorials/getting-started-xml-edition.rst +++ b/en/tutorials/getting-started-xml-edition.rst @@ -6,11 +6,11 @@ domain model in a non-interfering way. The Data Mapper pattern is at the heart of this project, aiming for a complete separation of the domain/business logic from the persistence in a relational database management system. The benefit of Doctrine for the -programmer is the possibility can focus solely on the business and +programmer is the ability to focus solely on the business logic and worry about persistence only as a secondary task. This doesn't mean persistence is not important to Doctrine 2, however it is our belief that there are considerable benefits for object-oriented -programming, if persistence and entities are kept perfectly +programming if persistence and entities are kept perfectly separated. What are Entities? From c89290e5077ade0080032d1cf5bdcf5947f713cb Mon Sep 17 00:00:00 2001 From: Ray Rehbein Date: Thu, 16 Dec 2010 06:12:58 +0800 Subject: [PATCH 2/9] Corrected mismatch between example and comment entities. --- en/reference/working-with-objects.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/reference/working-with-objects.rst b/en/reference/working-with-objects.rst index 08e950843..ccb1fae08 100644 --- a/en/reference/working-with-objects.rst +++ b/en/reference/working-with-objects.rst @@ -113,7 +113,7 @@ from newly opened EntityManager. $article = $em->find('Article', 1); -This code only retrieves the ``User`` instance with id 1 executing +This code only retrieves the ``Article`` instance with id 1 executing a single SELECT statement against the user table in the database. You can still access the associated properties author and comments and the associated objects they contain. From d81dca3e909270cb69d7fe2b42bda043e2d498fa Mon Sep 17 00:00:00 2001 From: Ray Rehbein Date: Thu, 16 Dec 2010 06:13:28 +0800 Subject: [PATCH 3/9] Corrected example calling wrong method name --- en/reference/working-with-associations.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/reference/working-with-associations.rst b/en/reference/working-with-associations.rst index e49194e5b..8edd54eaf 100644 --- a/en/reference/working-with-associations.rst +++ b/en/reference/working-with-associations.rst @@ -238,7 +238,7 @@ element. Here are some examples: $comment->getUserFavorites()->removeElement($user); // Remove by Key - $user->getComments()->removeElement($ithComment); + $user->getComments()->remove($ithComment); $comment->setAuthor(null); You need to call ``$em->flush()`` to make persist these changes in From 0411b1e75d645377042e1c6a7f28ff3a43f21e8a Mon Sep 17 00:00:00 2001 From: Ray Rehbein Date: Thu, 16 Dec 2010 06:14:08 +0800 Subject: [PATCH 4/9] Attempt at correction for a formatting glitch. It appears Sphinx doesn't use the `` mark in the middle of a word correctly --- en/reference/native-sql.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/reference/native-sql.rst b/en/reference/native-sql.rst index 3d976794a..dfec36ff8 100644 --- a/en/reference/native-sql.rst +++ b/en/reference/native-sql.rst @@ -58,7 +58,7 @@ components: .. note:: It might not surprise you that Doctrine uses - ``ResultSetMapping``s internally when you create DQL queries. As + ``ResultSetMapping`` internally when you create DQL queries. As the query gets parsed and transformed to SQL, Doctrine fills a ``ResultSetMapping`` that describes how the results should be processed by the hydration routines. From fc6cec90745ffd1f6e7220ca6372f3c903c47c0e Mon Sep 17 00:00:00 2001 From: Ray Rehbein Date: Thu, 16 Dec 2010 06:15:14 +0800 Subject: [PATCH 5/9] Added setParamater calls to examples Whitespace changes to break up the long SQL lines into a readable format --- en/reference/dql-doctrine-query-language.rst | 48 ++++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/en/reference/dql-doctrine-query-language.rst b/en/reference/dql-doctrine-query-language.rst index 18c9a4568..d745d8a98 100644 --- a/en/reference/dql-doctrine-query-language.rst +++ b/en/reference/dql-doctrine-query-language.rst @@ -259,6 +259,7 @@ With WHERE Clause and Positional Parameter: createQuery('SELECT u FROM ForumUser u WHERE u.id = ?1'); + $query->setParameter(1, 321); $users = $query->getResult(); // array of ForumUser objects With WHERE Clause and Named Parameter: @@ -267,6 +268,7 @@ With WHERE Clause and Named Parameter: createQuery('SELECT u FROM ForumUser u WHERE u.username = :name'); + $query->setParameter(':name', 'Bob'); $users = $query->getResult(); // array of ForumUser objects With Nested Conditions in WHERE Clause: @@ -275,6 +277,11 @@ With Nested Conditions in WHERE Clause: createQuery('SELECT u from ForumUser u WHERE (u.username = :name OR u.username = :name2) AND u.id = :id'); + $query->setParameters(array( + ':name' => 'Bob', + ':name' => 'Alice', + ':id' => 321, + )); $users = $query->getResult(); // array of ForumUser objects With COUNT DISTINCT: @@ -324,6 +331,8 @@ BETWEEN in WHERE clause: createQuery('SELECT u.name FROM CmsUser u WHERE u.id BETWEEN ?1 AND ?2'); + $query->setParameter(1, 123); + $query->setParameter(2, 321); $usernames = $query->getResult(); DQL Functions in WHERE clause: @@ -354,9 +363,11 @@ CONCAT() DQL Function: createQuery("SELECT u.id FROM CmsUser u WHERE CONCAT(u.name, 's') = ?1"); + $query->setParameter(1, 'Jess'); $ids = $query->getResult(); $query = $em->createQuery('SELECT CONCAT(u.id, u.name) FROM CmsUser u WHERE u.id = ?1'); + $query->setParameter(1, 321); $idUsernames = $query->getResult(); EXISTS in WHERE clause with correlated Subquery @@ -705,7 +716,12 @@ entities looks like the following: .. code-block:: sql - CREATE TABLE Person (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(50) NOT NULL, discr VARCHAR(255) NOT NULL, department VARCHAR(50) NOT NULL) + CREATE TABLE Person ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + name VARCHAR(50) NOT NULL, + discr VARCHAR(255) NOT NULL, + department VARCHAR(50) NOT NULL + ) Now when persist a new ``Employee`` instance it will set the discriminator value for us automatically: @@ -732,7 +748,9 @@ entities: .. code-block:: sql - SELECT p0_.id AS id0, p0_.name AS name1, p0_.department AS department2, p0_.discr AS discr3 FROM Person p0_ WHERE (p0_.name = ?) AND p0_.discr IN ('employee') + SELECT p0_.id AS id0, p0_.name AS name1, p0_.department AS department2, + p0_.discr AS discr3 FROM Person p0_ + WHERE (p0_.name = ?) AND p0_.discr IN ('employee') Class Table Inheritance ~~~~~~~~~~~~~~~~~~~~~~~ @@ -769,8 +787,17 @@ you'll notice some differences: .. code-block:: sql - CREATE TABLE Person (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, discr VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB; - CREATE TABLE Employee (id INT NOT NULL, department VARCHAR(50) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB; + CREATE TABLE Person ( + id INT AUTO_INCREMENT NOT NULL, + name VARCHAR(50) NOT NULL, + discr VARCHAR(255) NOT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; + CREATE TABLE Employee ( + id INT NOT NULL, + department VARCHAR(50) NOT NULL, + PRIMARY KEY(id) + ) ENGINE = InnoDB; ALTER TABLE Employee ADD FOREIGN KEY (id) REFERENCES Person(id) ON DELETE CASCADE @@ -784,7 +811,10 @@ automatically for you: .. code-block:: sql - SELECT p0_.id AS id0, p0_.name AS name1, e1_.department AS department2, p0_.discr AS discr3 FROM Employee e1_ INNER JOIN Person p0_ ON e1_.id = p0_.id WHERE p0_.name = ? + SELECT p0_.id AS id0, p0_.name AS name1, e1_.department AS department2, + p0_.discr AS discr3 + FROM Employee e1_ INNER JOIN Person p0_ ON e1_.id = p0_.id + WHERE p0_.name = ? The Query class @@ -826,7 +856,7 @@ the Query class. Here they are: pure/mixed distinction does not apply. - ``Query#getArrayResult()``: Retrieves an array graph (a nested array) that is largely interchangeable with the object graph - generated by ``Query#getResultList()`` for read-only purposes. + generated by ``Query#getResult()`` for read-only purposes. .. note:: @@ -850,7 +880,7 @@ general-purpose method Using this method you can directly supply the hydration mode as the second parameter via one of the Query constants. In fact, the methods mentioned earlier are just convenient shortcuts for the -execute method. For example, the method ``Query#getResultList()`` +execute method. For example, the method ``Query#getResult()`` internally invokes execute, passing in ``Query::HYDRATE_OBJECT`` as the hydration mode. @@ -914,10 +944,10 @@ Here is how the result could look like: array array [0] => User (Object) - ['nameUpper'] => "Roman" + ['nameUpper'] => "ROMAN" array [0] => User (Object) - ['nameUpper'] => "Jonathan" + ['nameUpper'] => "JONATHAN" ... And here is how you would access it in PHP code: From be8d34dc21caa71a00f8f610bd7400c7a7984e9d Mon Sep 17 00:00:00 2001 From: Ray Rehbein Date: Thu, 16 Dec 2010 06:17:46 +0800 Subject: [PATCH 6/9] Whitespace correction --- en/reference/query-builder.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/reference/query-builder.rst b/en/reference/query-builder.rst index 8cf459b15..da5bbf2cd 100644 --- a/en/reference/query-builder.rst +++ b/en/reference/query-builder.rst @@ -276,7 +276,7 @@ complete list of supported helper methods available: public function from($from, $alias); // Returns Expr\From instance // Example - $qb->expr()->leftJoin('u.Phonenumbers', 'p', Expr\Join::ON, 'p.user_id = u.id AND p.country_code = 55'); - // Example - $qb->expr()->leftJoin('u. Phonenumbers', 'p', 'ON', $qb->expr()->andx($qb->expr()->eq('p.user_id', 'u.id'), $qb->expr()->eq('p.country_code', '55')); + // Example - $qb->expr()->leftJoin('u.Phonenumbers', 'p', 'ON', $qb->expr()->andx($qb->expr()->eq('p.user_id', 'u.id'), $qb->expr()->eq('p.country_code', '55')); public function leftJoin($join, $alias, $conditionType = null, $condition = null); // Returns Expr\Join instance // Example - $qb->expr()->innerJoin('u.Group', 'g', Expr\Join::WITH, 'g.manager_level = 100'); From 2a38e5f408b3ec093c9277b3c52089e456644153 Mon Sep 17 00:00:00 2001 From: Ray Rehbein Date: Thu, 16 Dec 2010 22:58:37 +0800 Subject: [PATCH 7/9] Syntex and code correction in example --- en/reference/caching.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/reference/caching.rst b/en/reference/caching.rst index 1fe17a153..24d99b541 100644 --- a/en/reference/caching.rst +++ b/en/reference/caching.rst @@ -79,7 +79,7 @@ driver by itself. $memcache->connect('memcache_host', 11211); $cacheDriver = new \Doctrine\Common\Cache\MemcacheCache(); - $cacheDriver->setMemcache() + $cacheDriver->setMemcache($memcache); $cacheDriver->save('cache_id', 'my_data'); Xcache From 8fc7eb295bf7b6e776ec5510133064687c9fbf88 Mon Sep 17 00:00:00 2001 From: Ivar Nesje Date: Sat, 22 Jan 2011 19:42:48 +0800 Subject: [PATCH 8/9] Fixed lifecycleCallbacks documentation bug when using YAML mapping --- en/reference/events.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/en/reference/events.rst b/en/reference/events.rst index 836980d41..0a0f760e1 100644 --- a/en/reference/events.rst +++ b/en/reference/events.rst @@ -275,9 +275,9 @@ can do it with the following. # ... name: type: string(50) - lifecycleCallbacks: - doStuffOnPrePersist: prePersist - doStuffOnPostPersist: postPersist + lifecycleCallbacks: + prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] + postPersist: [ doStuffOnPostPersist ] XML would look something like this: From af60471b629bbd6a18a8c6bccef2071b8557ee41 Mon Sep 17 00:00:00 2001 From: Ivar Nesje Date: Sat, 22 Jan 2011 19:47:15 +0800 Subject: [PATCH 9/9] fixed indentation on previous commit --- en/reference/events.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/en/reference/events.rst b/en/reference/events.rst index 0a0f760e1..ccdf199c8 100644 --- a/en/reference/events.rst +++ b/en/reference/events.rst @@ -275,9 +275,9 @@ can do it with the following. # ... name: type: string(50) - lifecycleCallbacks: - prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] - postPersist: [ doStuffOnPostPersist ] + lifecycleCallbacks: + prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] + postPersist: [ doStuffOnPostPersist ] XML would look something like this: