Changeset 5032
- Timestamp:
- 10/02/08 07:07:05 (3 months ago)
- Location:
- branches/1.1
- Files:
-
- 1 added
- 3 modified
-
lib/Doctrine/Collection.php (modified) (1 diff)
-
tests/run.php (modified) (1 diff)
-
tests/Ticket/1338TestCase.php (added)
-
UPGRADE_TO_1_1 (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1/lib/Doctrine/Collection.php
r4957 r5032 684 684 685 685 /** 686 * Build an array made up of the values from the 2 specified columns 687 * 688 * @param string $key 689 * @param string $value 690 * @return array $result 691 */ 692 public function toKeyValueArray($key, $value) 693 { 694 $result = array(); 695 foreach ($this as $record) { 696 $result[$record->$key] = $record->$value; 697 } 698 return $result; 699 } 700 701 /** 686 702 * Populate a Doctrine_Collection from an array of data 687 703 * -
branches/1.1/tests/run.php
r5030 r5032 132 132 $tickets->addTestCase(new Doctrine_Ticket_1326_TestCase()); 133 133 $tickets->addTestCase(new Doctrine_Ticket_1335_TestCase()); 134 $tickets->addTestCase(new Doctrine_Ticket_1338_TestCase()); 134 135 $tickets->addTestCase(new Doctrine_Ticket_1351_TestCase()); 135 136 $tickets->addTestCase(new Doctrine_Ticket_1365_TestCase()); -
branches/1.1/UPGRADE_TO_1_1
r5031 r5032 13 13 ->where('u.id IN ?', array(1, 2, 3)); 14 14 $users = $q->execute(); 15 16 [r5018](http://trac.doctrine-project.org/changeset/5018) - Added `Doctrine::ATTR_AUTO_FREE_QUERY_OBJECTS` for auto freeing query objects after execution17 18 $manager->setAttribute('auto_free_query_objects');19 $q = Doctrine_Query::create()20 ->from('User u')21 $users = $q->execute(); // $q->free() is triggered22 15 23 16 [r5019](http://trac.doctrine-project.org/changeset/5019) - `unlink()` and `link()` have been changed to not delete references until `save()` is called on the object. Also, fixed synchronizeWithArray() to synchronize many to many relationships. … … 43 36 $user->synchronizeWithArray($userArray); 44 37 $user->save(); 38 39 Default Options 40 --------------- 45 41 46 42 [r5027](http://trac.doctrine-project.org/changeset/5039) - Added support for setting default charset and collate for tables. … … 86 82 $q->select(); 87 83 $user = $q->fetchOne(); 84 85 [r5018](http://trac.doctrine-project.org/changeset/5018) - Added `Doctrine::ATTR_AUTO_FREE_QUERY_OBJECTS` for auto freeing query objects after execution 86 87 $manager->setAttribute('auto_free_query_objects'); 88 $q = Doctrine_Query::create() 89 ->from('User u') 90 $users = $q->execute(); // $q->free() is triggered 91 92 Doctrine Collection 93 ------------------- 94 95 You can now convert a Doctrine_Collection in to a key value array made up of the values from the two specified columns. 96 97 $q = Doctrine_Query::create() 98 ->from('User u'); 99 $users = $q->execute(); 100 101 $array = $users->toKeyValueArray('id', 'name'); 102 print_r($array); 103 104 /* 105 array( 106 4 => 'zYne', 107 5 => 'Arnold Schwarzenegger', 108 6 => 'Michael Caine', 109 7 => 'Takeshi Kitano', 110 8 => 'Sylvester Stallone', 111 9 => 'Kurt Russell', 112 10 => 'Jean Reno', 113 11 => 'Edward Furlong', 114 ) 115 */