diff --git a/manual/en/basic-mapping.txt b/manual/en/basic-mapping.txt index 70a098e26..8acf712eb 100644 --- a/manual/en/basic-mapping.txt +++ b/manual/en/basic-mapping.txt @@ -71,6 +71,8 @@ For example, the Doctrine Mapping Type `string` defines the mapping from a PHP s * `time`: Type that maps an SQL TIME to a PHP DateTime object. * `datetime`: Type that maps an SQL DATETIME/TIMESTAMP to a PHP DateTime object. * `text`: Type that maps an SQL CLOB to a PHP string. +* `object`: Type that maps a SQL CLOB to a PHP object using `serialize()` and `unserialize()` +* `array`: Type that maps a SQL CLOB to a PHP object using `serialize()` and `unserialize()` > **NOTE** > Doctrine Mapping Types are NOT SQL types and NOT PHP types! They are mapping types @@ -189,6 +191,17 @@ for the mapping type and map that to the corresponding fully qualified class nam private $field; } +To have Schema-Tool convert the underlying database type of your new "mytype" directly into an instance of `MyType` +you have to additionally register this mapping with your database platform: + + [php] + $conn = $em->getConnection(); + $conn->getDatabasePlatform()->registerDoctrineTypeMapping('db_mytype', 'mytype'); + +Now using Schema-Tool, whenever it detects a column having the `db_mytype` it will convert it into a `mytype` +Doctrine Type instance for Schema representation. Keep in mind that you can easily produce clashes this way, +each database type can only map to exactly one Doctrine mapping type. + ++ Identifiers / Primary Keys Every entity class needs an identifier/primary key. You designate the field that serves as the identifier with the `@Id` marker annotation. Here is an example: diff --git a/manual/en/working-with-objects.txt b/manual/en/working-with-objects.txt index 588082e11..e69adacdb 100644 --- a/manual/en/working-with-objects.txt +++ b/manual/en/working-with-objects.txt @@ -256,6 +256,15 @@ that has O(n) complexity, where n is the size of the map. Since Doctrine always only looks at the owning side of a bidirectional association, it is essentially not necessary that an inverse collection of a bidirectional one-to-many or many-to-many association is updated. This knowledge can often be used to improve performance by avoiding the loading of the inverse collection. +> **NOTE* +> +> You can also clear the contents of a whole collection using the `Collections::clear()` method. You +> should be aware that using this method can lead to a straight and optimized database delete or update call +> during the flush operation that is not aware of entities that have been re-added to the collection. +> +> Say you clear a collection of tags by calling `$post->getTags()->clear();` and then call +> `$post->getTags()->add($tag)`. This will not recognize tag being already added before and issue +> two database calls. ++ Association Management Methods