Changeset 2296 for trunk/manual
- Timestamp:
- 08/30/07 23:04:41 (17 months ago)
- Files:
-
- 1 modified
-
trunk/manual/new/docs/en/mapping-relations.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/manual/new/docs/en/mapping-relations.txt
r2163 r2296 175 175 } 176 176 177 class GroupUser extends Doctrine_Record 177 class GroupUser extends Doctrine_Record 178 178 { 179 179 public function setTableDefinition() … … 300 300 301 301 +++ One table, one class 302 303 One-table-one-class inheritance is the only inheritance type that allows additional fields for inherited classes. As shown in the example above adding additional columns is very easy: 304 305 <code type="php"> 306 class TextItem extends Doctrine_Record 307 { 308 public function setTableDefinition() 309 { 310 $this->hasColumn('topic', 'string', 100); 311 } 312 } 313 314 class Comment extends TextItem 315 { 316 public function setTableDefinition() 317 { 318 parent::setTableDefinition(); 319 320 $this->hasColumn('content', 'string', 300); 321 } 322 } 323 </code> 324 325 326 In one-table-one-class inheritance you don't necessarily have to define additional columns, but in order to make Doctrine create separate tables for each class you'll have to make iterative setTableDefinition() calls. 302 327 303 328 In the following example we have three database tables called {{entity}}, {{user}} and {{group}}. Users and groups are both entities. The only thing we have to do is write 3 classes ({{Entity}}, {{Group}} and {{User}}) and make iterative {{setTableDefinition}} method calls.