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 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: diff --git a/en/reference/events.rst b/en/reference/events.rst index 836980d41..ccdf199c8 100644 --- a/en/reference/events.rst +++ b/en/reference/events.rst @@ -276,8 +276,8 @@ can do it with the following. name: type: string(50) lifecycleCallbacks: - doStuffOnPrePersist: prePersist - doStuffOnPostPersist: postPersist + prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] + postPersist: [ doStuffOnPostPersist ] XML would look something like this: 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. 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 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. 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?