Changeset 4699 for trunk/tests/models
- Timestamp:
- 07/20/08 21:13:24 (6 months ago)
- Location:
- trunk/tests/models
- Files:
-
- 1 added
- 8 modified
-
cms/CmsArticle.php (modified) (1 diff)
-
cms/CmsComment.php (modified) (1 diff)
-
cms/CmsPhonenumber.php (modified) (1 diff)
-
cms/CmsUser.php (modified) (1 diff)
-
forum/ForumAdministrator.php (modified) (1 diff)
-
forum/ForumBoard.php (modified) (2 diffs)
-
forum/ForumCategory.php (modified) (1 diff)
-
forum/ForumEntry.php (added)
-
forum/ForumUser.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/models/cms/CmsArticle.php
r4422 r4699 1 1 <?php 2 3 #namespace Doctrine::Tests::ORM::Models::CMS; 4 5 #use Doctrine::ORM::Entity; 6 2 7 class CmsArticle extends Doctrine_Entity 3 8 { 4 public static function initMetadata($class) 5 { 6 $class->mapColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true)); 7 $class->mapColumn('topic', 'string', 255); 8 $class->mapColumn('text', 'string'); 9 $class->mapColumn('user_id', 'integer', 4); 10 $class->hasMany('CmsComment as comments', array( 11 'local' => 'id', 'foreign' => 'article_id')); 12 } 9 #protected $id; 10 #protected $topic; 11 #protected $text; 12 #protected $user_id; 13 14 public static function initMetadata($mapping) 15 { 16 $mapping->mapField(array( 17 'fieldName' => 'id', 18 'type' => 'integer', 19 'length' => 4, 20 'id' => true, 21 'generatorType' => 'auto' 22 )); 23 $mapping->mapField(array( 24 'fieldName' => 'topic', 25 'type' => 'string', 26 'length' => 255 27 )); 28 $mapping->mapField(array( 29 'fieldName' => 'text', 30 'type' => 'string' 31 )); 32 $mapping->mapField(array( 33 'fieldName' => 'user_id', 34 'type' => 'integer', 35 'length' => 4 36 )); 37 $mapping->hasMany('CmsComment as comments', array( 38 'local' => 'id', 'foreign' => 'article_id')); 39 } 13 40 } -
trunk/tests/models/cms/CmsComment.php
r4422 r4699 1 1 <?php 2 3 #namespace Doctrine::Tests::ORM::Models::CMS; 4 5 #use Doctrine::ORM::Entity; 6 2 7 class CmsComment extends Doctrine_Entity 3 8 { 4 public static function initMetadata($class) 5 { 6 $class->mapColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true)); 7 $class->mapColumn('topic', 'string', 255); 8 $class->mapColumn('text', 'string'); 9 $class->mapColumn('article_id', 'integer', 4); 10 } 9 #protected $id; 10 #protected $topic; 11 #protected $text; 12 #protected $article_id; 13 14 public static function initMetadata($mapping) 15 { 16 $mapping->mapField(array( 17 'fieldName' => 'id', 18 'type' => 'integer', 19 'length' => 4, 20 'id' => true, 21 'generatorType' => 'auto' 22 )); 23 $mapping->mapField(array( 24 'fieldName' => 'topic', 25 'type' => 'string', 26 'length' => 255 27 )); 28 $mapping->mapField(array( 29 'fieldName' => 'text', 30 'type' => 'string' 31 )); 32 $mapping->mapField(array( 33 'fieldName' => 'article_id', 34 'type' => 'integer', 35 'length' => 4 36 )); 37 } 11 38 } -
trunk/tests/models/cms/CmsPhonenumber.php
r4422 r4699 2 2 class CmsPhonenumber extends Doctrine_Entity 3 3 { 4 public static function initMetadata($class) 5 { 6 $class->mapColumn('user_id', 'integer', 4); 7 $class->mapColumn('phonenumber', 'string', 50, array('primary' => true)); 8 } 4 #protected $user_id; 5 #protected $phonenumber; 6 7 public static function initMetadata($mapping) 8 { 9 $mapping->mapField(array( 10 'fieldName' => 'user_id', 11 'type' => 'integer', 12 'length' => 4 13 )); 14 $mapping->mapField(array( 15 'fieldName' => 'phonenumber', 16 'type' => 'string', 17 'length' => 50, 18 'id' => true 19 )); 20 } 9 21 } -
trunk/tests/models/cms/CmsUser.php
r4374 r4699 1 1 <?php 2 3 #namespace Doctrine::Test::ORM::Models; 4 5 #use Doctrine::ORM::Entity; 6 2 7 class CmsUser extends Doctrine_Entity 3 8 { 4 public static function initMetadata($class) 5 { 6 $class->mapColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true)); 7 $class->mapColumn('status', 'string', 50); 8 $class->mapColumn('username', 'string', 255); 9 $class->mapColumn('name', 'string', 255); 10 11 $class->hasMany('CmsPhonenumber as phonenumbers', array( 9 #protected $id; 10 #protected $status; 11 #protected $username; 12 #protected $name; 13 14 public static function initMetadata($mapping) 15 { 16 $mapping->mapField(array( 17 'fieldName' => 'id', 18 'type' => 'integer', 19 'length' => 4, 20 'id' => true, 21 'generatorType' => 'auto' 22 )); 23 $mapping->mapField(array( 24 'fieldName' => 'status', 25 'type' => 'string', 26 'length' => 50 27 )); 28 $mapping->mapField(array( 29 'fieldName' => 'username', 30 'type' => 'string', 31 'length' => 255 32 )); 33 $mapping->mapField(array( 34 'fieldName' => 'name', 35 'type' => 'string', 36 'length' => 255 37 )); 38 39 $mapping->hasMany('CmsPhonenumber as phonenumbers', array( 12 40 'local' => 'id', 'foreign' => 'user_id')); 13 $class->hasMany('CmsArticle as articles', array(41 $mapping->hasMany('CmsArticle as articles', array( 14 42 'local' => 'id', 'foreign' => 'user_id')); 15 }43 } 16 44 } -
trunk/tests/models/forum/ForumAdministrator.php
r4101 r4699 3 3 class ForumAdministrator extends ForumUser 4 4 { 5 public static function initMetadata($ class)5 public static function initMetadata($mapping) 6 6 { 7 $class->mapColumn('access_level as accessLevel', 'integer', 1); 7 $mapping->mapField(array( 8 'fieldName' => 'accessLevel', 9 'columnName' => 'access_level', 10 'type' => 'integer', 11 'length' => 1 12 )); 8 13 } 9 14 -
trunk/tests/models/forum/ForumBoard.php
r4653 r4699 1 1 <?php 2 class ForumBoard extends Doctrine_Entity { 3 public static function initMetadata($metadata) { 2 class ForumBoard extends Doctrine_Entity 3 { 4 public static function initMetadata($mapping) 5 { 4 6 /*$metadata->mapField(array( 5 7 'fieldName' => 'id', … … 9 11 )); 10 12 */ 11 $metadata->mapColumn('id', 'integer', 4, array('primary')); 12 $metadata->mapColumn('position', 'integer'); 13 $metadata->mapColumn('category_id', 'integer'); 14 $metadata->hasOne('ForumCategory as category', 13 $mapping->mapField(array( 14 'fieldName' => 'id', 15 'type' => 'integer', 16 'length' => 4, 17 'id' => true 18 )); 19 $mapping->mapField(array( 20 'fieldName' => 'position', 21 'type' => 'integer' 22 )); 23 $mapping->mapField(array( 24 'fieldName' => 'category_id', 25 'type' => 'integer' 26 )); 27 28 $mapping->hasOne('ForumCategory as category', 15 29 array('local' => 'category_id', 'foreign' => 'id')); 16 30 /* -
trunk/tests/models/forum/ForumCategory.php
r4653 r4699 1 1 <?php 2 class ForumCategory extends Doctrine_Entity { 3 public static function initMetadata($class) { 4 $class->mapColumn('id', 'integer', 4, array('primary')); 5 $class->mapColumn('position', 'integer'); 6 $class->mapColumn('name', 'string', 255); 7 $class->hasMany('ForumBoard as boards', array( 2 class ForumCategory extends Doctrine_Entity 3 { 4 5 public static function initMetadata($mapping) 6 { 7 $mapping->mapField(array( 8 'fieldName' => 'id', 9 'type' => 'integer', 10 'length' => 4, 11 'id' => true 12 )); 13 $mapping->mapField(array( 14 'fieldName' => 'position', 15 'type' => 'integer' 16 )); 17 $mapping->mapField(array( 18 'fieldName' => 'name', 19 'type' => 'string', 20 'length' => 255 21 )); 22 23 $mapping->hasMany('ForumBoard as boards', array( 8 24 'local' => 'id' , 'foreign' => 'category_id')); 9 25 } -
trunk/tests/models/forum/ForumUser.php
r4437 r4699 1 1 <?php 2 3 #namespace Doctrine::Tests::ORM::Models::Forum; 4 5 #use Doctrine::ORM::Entity; 2 6 3 7 class ForumUser extends Doctrine_Entity 4 8 { 5 public static function initMetadata($class) 9 #protected $dtype; 10 #protected $id; 11 #protected $username; 12 13 public static function initMetadata($mapping) 6 14 { 7 15 // inheritance mapping 8 $ class->setInheritanceType(Doctrine::INHERITANCE_TYPE_JOINED, array(16 $mapping->setInheritanceType('joined', array( 9 17 'discriminatorColumn' => 'dtype', 10 18 'discriminatorMap' => array( … … 13 21 )); 14 22 // register subclasses 15 $ class->setSubclasses(array('ForumAdministrator'));23 $mapping->setSubclasses(array('ForumAdministrator')); 16 24 // the discriminator column 17 $class->mapColumn('dtype', 'string', 50); 25 $mapping->mapField(array( 26 'fieldName' => 'dtype', 27 'type' => 'string', 28 'length' => 50 29 )); 18 30 19 31 // column-to-field mapping 20 $class->mapColumn('id', 'integer', 4, array( 21 'primary' => true, 22 'autoincrement' => true)); 23 $class->mapColumn('username', 'string', 50, array()); 32 $mapping->mapField(array( 33 'fieldName' => 'id', 34 'type' => 'integer', 35 'length' => 4, 36 'id' => true, 37 'generatorType' => 'auto' 38 )); 39 $mapping->mapField(array( 40 'fieldName' => 'username', 41 'type' => 'string', 42 'length' => 50 43 )); 24 44 25 45 }