diff --git a/lib/Doctrine/Collection.php b/lib/Doctrine/Collection.php index cb26f3bd5..b67a72770 100644 --- a/lib/Doctrine/Collection.php +++ b/lib/Doctrine/Collection.php @@ -718,7 +718,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator } /** - * synchronizeWithArray + * synchronizeFromArray * synchronizes a Doctrine_Collection with data from an array * * it expects an array representation of a Doctrine_Collection similar to the return @@ -727,17 +727,18 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator * * @param array $array representation of a Doctrine_Collection */ - public function synchronizeWithArray(array $array) + public function synchronizeFromArray(array $array) { foreach ($this as $key => $record) { if (isset($array[$key])) { - $record->synchronizeWithArray($array[$key]); + $record->synchronizeFromArray($array[$key]); unset($array[$key]); } else { // remove records that don't exist in the array $this->remove($key); } } + // create new records for each new row in the array foreach ($array as $rowKey => $row) { $this[$rowKey]->fromArray($row); diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index bc074a770..f49e9818b 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -1324,8 +1324,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count { foreach ($array as $key => $value) { if ($this->getTable()->hasRelation($key)) { - $this->get($key)->synchronizeWithArray($value); - } else if ($this->getTable()->hasField($key)) { + $this->get($key)->synchronizeFromArray($value); + } else if ($this->getTable()->hasColumn($key)) { $this->set($key, $value); } } diff --git a/lib/Doctrine/Record/Abstract.php b/lib/Doctrine/Record/Abstract.php index a10b2fdd3..6eeb838ea 100644 --- a/lib/Doctrine/Record/Abstract.php +++ b/lib/Doctrine/Record/Abstract.php @@ -211,9 +211,7 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access */ public function ownsOne() { - $this->_table->bind(func_get_args(), Doctrine_Relation::ONE_COMPOSITE); - - return $this; + throw new Doctrine_Exception('ownsMany() has been deprecated.'); } /** @@ -229,8 +227,7 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access */ public function ownsMany() { - $this->_table->bind(func_get_args(), Doctrine_Relation::MANY_COMPOSITE); - return $this; + throw new Doctrine_Exception('ownsOne() has been deprecated.'); } /** diff --git a/models/Entity.php b/models/Entity.php index 0e5cc0741..b8947a6b1 100644 --- a/models/Entity.php +++ b/models/Entity.php @@ -3,9 +3,9 @@ class Entity extends Doctrine_Record { public function setUp() { - $this->ownsOne('Email', array('local' => 'email_id')); + $this->hasOne('Email', array('local' => 'email_id')); $this->hasMany('Phonenumber', array('local' => 'id', 'foreign' => 'entity_id')); - $this->ownsOne('Account', array('foreign' => 'entity_id')); + $this->hasOne('Account', array('foreign' => 'entity_id')); $this->hasMany('Entity', array('local' => 'entity1', 'refClass' => 'EntityReference', 'foreign' => 'entity2', diff --git a/models/Error.php b/models/Error.php index 76f2cfb2e..36c029e69 100644 --- a/models/Error.php +++ b/models/Error.php @@ -1,7 +1,7 @@ ownsMany('Description', 'Description.file_md5', 'file_md5'); + $this->hasMany('Description', 'Description.file_md5', 'file_md5'); } public function setTableDefinition() { $this->hasColumn('message', 'string',200); diff --git a/models/FilterTest.php b/models/FilterTest.php index df0cb69a9..707d889e2 100644 --- a/models/FilterTest.php +++ b/models/FilterTest.php @@ -4,6 +4,6 @@ class FilterTest extends Doctrine_Record { $this->hasColumn('name', 'string',100); } public function setUp() { - $this->ownsMany('FilterTest2 as filtered', 'FilterTest2.test1_id'); + $this->hasMany('FilterTest2 as filtered', 'FilterTest2.test1_id'); } } diff --git a/models/Package.php b/models/Package.php index 2554dc2e2..a5b5e5f7d 100644 --- a/models/Package.php +++ b/models/Package.php @@ -6,6 +6,6 @@ class Package extends Doctrine_Record { public function setUp() { - $this->ownsMany('PackageVersion as Version', 'PackageVersion.package_id'); + $this->hasMany('PackageVersion as Version', 'PackageVersion.package_id'); } } diff --git a/models/QueryTest_Board.php b/models/QueryTest_Board.php index dbee0c97f..6a5fad158 100644 --- a/models/QueryTest_Board.php +++ b/models/QueryTest_Board.php @@ -22,6 +22,6 @@ class QueryTest_Board extends Doctrine_Record public function setUp() { $this->hasOne('QueryTest_Category as category', 'QueryTest_Board.categoryId'); - $this->ownsOne('QueryTest_Entry as lastEntry', 'QueryTest_Board.lastEntryId'); + $this->hasOne('QueryTest_Entry as lastEntry', 'QueryTest_Board.lastEntryId'); } } diff --git a/models/QueryTest_Category.php b/models/QueryTest_Category.php index f4d837de4..8c432d6db 100644 --- a/models/QueryTest_Category.php +++ b/models/QueryTest_Category.php @@ -29,8 +29,8 @@ class QueryTest_Category extends Doctrine_Record */ public function setUp() { - $this->ownsMany('QueryTest_Category as subCategories', 'subCategories.parentCategoryId'); + $this->hasMany('QueryTest_Category as subCategories', 'subCategories.parentCategoryId'); $this->hasOne('QueryTest_Category as rootCategory', 'QueryTest_Category.rootCategoryId'); - $this->ownsMany('QueryTest_Board as boards', 'QueryTest_Board.categoryId'); + $this->hasMany('QueryTest_Board as boards', 'QueryTest_Board.categoryId'); } } diff --git a/models/Rec1.php b/models/Rec1.php index 32ef64f25..52dd07546 100644 --- a/models/Rec1.php +++ b/models/Rec1.php @@ -8,7 +8,7 @@ class Rec1 extends Doctrine_Record public function setUp() { - $this->ownsOne('Rec2 as Account', array('local' => 'id', 'foreign' => 'user_id')); + $this->hasOne('Rec2 as Account', array('local' => 'id', 'foreign' => 'user_id')); } } diff --git a/models/Rec2.php b/models/Rec2.php index 45a35c517..02341f607 100644 --- a/models/Rec2.php +++ b/models/Rec2.php @@ -9,7 +9,7 @@ class Rec2 extends Doctrine_Record public function setUp() { - $this->ownsOne('Rec1 as User', 'Rec2.user_id'); + $this->hasOne('Rec1 as User', 'Rec2.user_id'); } } diff --git a/models/ValidatorTest_Person.php b/models/ValidatorTest_Person.php index b4b191af3..58ef41e19 100644 --- a/models/ValidatorTest_Person.php +++ b/models/ValidatorTest_Person.php @@ -6,6 +6,6 @@ class ValidatorTest_Person extends Doctrine_Record { } public function setUp() { - $this->ownsOne('ValidatorTest_FootballPlayer', 'ValidatorTest_FootballPlayer.person_id'); + $this->hasOne('ValidatorTest_FootballPlayer', 'ValidatorTest_FootballPlayer.person_id'); } } diff --git a/tests/Record/SynchronizeTestCase.php b/tests/Record/SynchronizeTestCase.php index 189909ace..c1d26eac9 100644 --- a/tests/Record/SynchronizeTestCase.php +++ b/tests/Record/SynchronizeTestCase.php @@ -60,13 +60,13 @@ class Doctrine_Record_Synchronize_TestCase extends Doctrine_UnitTestCase // delete a Phonenumber array_pop($userArray['Phonenumber']); - $user->synchronizeWithArray($userArray); + $user->synchronizeFromArray($userArray); $this->assertEqual($user->Phonenumber->count(), 1); $this->assertEqual($user->Phonenumber[0]->phonenumber, '555 321'); // change Email $userArray['Email']['address'] = 'johndow@mail.com'; - $user->synchronizeWithArray($userArray); + $user->synchronizeFromArray($userArray); $this->assertEqual($user->Email->address, 'johndow@mail.com'); $user->save(); @@ -86,7 +86,7 @@ class Doctrine_Record_Synchronize_TestCase extends Doctrine_UnitTestCase $userArray = $user->toArray(true); $userArray['Phonenumber'][] = array('phonenumber' => '333 238'); - $user->synchronizeWithArray($userArray); + $user->synchronizeFromArray($userArray); $this->assertEqual($user->Phonenumber->count(), 2); $this->assertEqual($user->Phonenumber[1]->phonenumber, '333 238'); $user->save(); @@ -106,7 +106,7 @@ class Doctrine_Record_Synchronize_TestCase extends Doctrine_UnitTestCase unset($userArray['Phonenumber']); unset($userArray['Email']); - $user->synchronizeWithArray($userArray); + $user->synchronizeFromArray($userArray); $this->assertEqual($user->Phonenumber->count(), 0); $this->assertTrue(!isset($user->Email)); $user->save(); diff --git a/tests/TableTestCase.php b/tests/TableTestCase.php index e76bbf1f3..15d56bd00 100644 --- a/tests/TableTestCase.php +++ b/tests/TableTestCase.php @@ -106,7 +106,7 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase $fk = $this->objTable->getTable()->getRelation("Email"); $this->assertTrue($fk instanceof Doctrine_Relation_LocalKey); $this->assertTrue($fk->getTable() instanceof Doctrine_Table); - $this->assertTrue($fk->getType() == Doctrine_Relation::ONE_COMPOSITE); + $this->assertTrue($fk->getType() == Doctrine_Relation::ONE_AGGREGATE); $this->assertTrue($fk->getLocal() == "email_id"); $this->assertTrue($fk->getForeign() == $fk->getTable()->getIdentifier());