Changeset 4829
- Timestamp:
- 08/27/08 03:30:02 (5 months ago)
- Location:
- branches/1.0
- Files:
-
- 12 modified
-
lib/Doctrine/Record/Abstract.php (modified) (1 diff)
-
lib/Doctrine/Table.php (modified) (1 diff)
-
tests/models/Entity.php (modified) (1 diff)
-
tests/models/FilterTest.php (modified) (1 diff)
-
tests/models/Package.php (modified) (1 diff)
-
tests/models/QueryTest_Board.php (modified) (2 diffs)
-
tests/models/QueryTest_Category.php (modified) (2 diffs)
-
tests/models/QueryTest_Entry.php (modified) (1 diff)
-
tests/models/Rec1.php (modified) (1 diff)
-
tests/models/Rec2.php (modified) (1 diff)
-
tests/models/ValidatorTest_Person.php (modified) (1 diff)
-
tests/TableTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/lib/Doctrine/Record/Abstract.php
r4778 r4829 184 184 185 185 /** 186 * DEPRECATED ALSO? - REMOVE SOON187 *188 * ownsOne189 * binds One-to-One composite relation190 *191 * @param string $componentName the name of the related component192 * @param string $options relation options193 * @see Doctrine_Relation::_$definition194 * @return Doctrine_Record this object195 */196 public function ownsOne()197 {198 $this->_table->bind(func_get_args(), Doctrine_Relation::ONE_COMPOSITE);199 200 return $this;201 }202 203 /**204 * DEPRECATED - REMOVE SOON205 *206 * ownsMany207 * binds One-to-Many / Many-to-Many composite relation208 *209 * @param string $componentName the name of the related component210 * @param string $options relation options211 * @see Doctrine_Relation::_$definition212 * @return Doctrine_Record this object213 */214 public function ownsMany()215 {216 $this->_table->bind(func_get_args(), Doctrine_Relation::MANY_COMPOSITE);217 return $this;218 }219 220 /**221 186 * hasOne 222 187 * binds One-to-One aggregate relation -
branches/1.0/lib/Doctrine/Table.php
r4823 r4829 639 639 if ($relation->getTable() === $this && in_array($relation->getLocal(), $primary)) { 640 640 if ($relation->hasConstraint()) { 641 throw new Doctrine_Table_Exception("Badly constructed integrity constraints. ");641 throw new Doctrine_Table_Exception("Badly constructed integrity constraints. Cannot define constraint of different fields in the same table."); 642 642 } 643 643 continue; -
branches/1.0/tests/models/Entity.php
r4121 r4829 4 4 public function setUp() 5 5 { 6 $this-> ownsOne('Email', array('local' => 'email_id'));6 $this->hasOne('Email', array('local' => 'email_id', 'onDelete' => 'CASCADE')); 7 7 $this->hasMany('Phonenumber', array('local' => 'id', 'foreign' => 'entity_id')); 8 $this-> ownsOne('Account', array('foreign' => 'entity_id'));8 $this->hasOne('Account', array('foreign' => 'entity_id', 'onDelete' => 'CASCADE')); 9 9 $this->hasMany('Entity', array('local' => 'entity1', 10 10 'refClass' => 'EntityReference', -
branches/1.0/tests/models/FilterTest.php
r2353 r4829 5 5 } 6 6 public function setUp() { 7 $this-> ownsMany('FilterTest2 as filtered', 'FilterTest2.test1_id');7 $this->hasMany('FilterTest2 as filtered', array('local' => 'id', 'foreign' => 'test1_id', 'onDelete' => 'CASCADE')); 8 8 } 9 9 } -
branches/1.0/tests/models/Package.php
r2353 r4829 7 7 public function setUp() 8 8 { 9 $this-> ownsMany('PackageVersion as Version', 'PackageVersion.package_id');9 $this->hasMany('PackageVersion as Version', array('local' => 'id', 'foreign' => 'package_id', 'onDelete' => 'CASCADE')); 10 10 } 11 11 } -
branches/1.0/tests/models/QueryTest_Board.php
r4652 r4829 6 6 */ 7 7 public function setTableDefinition() 8 { 8 { 9 $this->hasColumn('id', 'integer', 4, array('primary', 'autoincrement', 'notnull')); 9 10 $this->hasColumn('categoryId as categoryId', 'integer', 4, 10 11 array('notnull')); … … 22 23 public function setUp() 23 24 { 24 $this->hasOne('QueryTest_Category as category', 'QueryTest_Board.categoryId'); 25 $this->ownsOne('QueryTest_Entry as lastEntry', 'QueryTest_Board.lastEntryId'); 25 $this->hasOne('QueryTest_Category as category', array( 26 'local' => 'categoryId', 'foreign' => 'id' 27 )); 28 $this->hasOne('QueryTest_Entry as lastEntry', array( 29 'local' => 'lastEntryId', 'foreign' => 'id', 'onDelete' => 'CASCADE' 30 )); 26 31 } 27 32 } -
branches/1.0/tests/models/QueryTest_Category.php
r2963 r4829 14 14 */ 15 15 public function setTableDefinition() 16 { 16 { 17 $this->hasColumn('id', 'integer', 4, array('primary', 'autoincrement', 'notnull')); 17 18 $this->hasColumn('rootCategoryId as rootCategoryId', 'integer', 4, 18 array(' default' => 0));19 array('notnull', 'default' => 0)); 19 20 $this->hasColumn('parentCategoryId as parentCategoryId', 'integer', 4, 20 21 array('notnull', 'default' => 0)); … … 30 31 public function setUp() 31 32 { 32 $this->ownsMany('QueryTest_Category as subCategories', 'subCategories.parentCategoryId'); 33 $this->hasOne('QueryTest_Category as rootCategory', 'QueryTest_Category.rootCategoryId'); 34 $this->ownsMany('QueryTest_Board as boards', 'QueryTest_Board.categoryId'); 33 $this->hasMany('QueryTest_Category as subCategories', array( 34 'local' => 'id', 'foreign' => 'parentCategoryId' 35 )); 36 $this->hasOne('QueryTest_Category as rootCategory', array( 37 'local' => 'rootCategoryId', 'foreign' => 'id' 38 )); 39 $this->hasMany('QueryTest_Board as boards', array( 40 'local' => 'id', 'foreign' => 'categoryId', 'onDelete' => 'CASCADE' 41 )); 35 42 } 36 43 } -
branches/1.0/tests/models/QueryTest_Entry.php
r2963 r4829 7 7 public function setTableDefinition() 8 8 { 9 $this->hasColumn('id', 'integer', 4, array('primary', 'autoincrement', 'notnull')); 9 10 $this->hasColumn('authorId', 'integer', 4, 10 11 array('notnull')); -
branches/1.0/tests/models/Rec1.php
r2353 r4829 9 9 public function setUp() 10 10 { 11 $this-> ownsOne('Rec2 as Account', array('local' => 'id', 'foreign' => 'user_id'));11 $this->hasOne('Rec2 as Account', array('local' => 'id', 'foreign' => 'user_id', 'onDelete' => 'CASCADE')); 12 12 } 13 13 } -
branches/1.0/tests/models/Rec2.php
r2353 r4829 10 10 public function setUp() 11 11 { 12 $this-> ownsOne('Rec1 as User', 'Rec2.user_id');12 $this->hasOne('Rec1 as User', array('local' => 'id', 'foreign' => 'user_id', 'onDelete' => 'CASCADE')); 13 13 } 14 14 -
branches/1.0/tests/models/ValidatorTest_Person.php
r2353 r4829 7 7 8 8 public function setUp() { 9 $this->ownsOne('ValidatorTest_FootballPlayer', 'ValidatorTest_FootballPlayer.person_id'); 9 $this->hasOne('ValidatorTest_FootballPlayer', array( 10 'local' => 'id', 'foreign' => 'person_id', 'onDelete' => 'CASCADE' 11 )); 10 12 } 11 13 } -
branches/1.0/tests/TableTestCase.php
r3977 r4829 107 107 $this->assertTrue($fk instanceof Doctrine_Relation_LocalKey); 108 108 $this->assertTrue($fk->getTable() instanceof Doctrine_Table); 109 $this->assertTrue($fk->getType() == Doctrine_Relation::ONE_ COMPOSITE);109 $this->assertTrue($fk->getType() == Doctrine_Relation::ONE_AGGREGATE); 110 110 $this->assertTrue($fk->getLocal() == "email_id"); 111 111 $this->assertTrue($fk->getForeign() == $fk->getTable()->getIdentifier());