Changeset 4772
- Timestamp:
- 08/15/08 10:54:16 (11 months ago)
- Location:
- branches/1.0
- Files:
-
- 2 added
- 3 modified
-
lib/Doctrine/Record.php (modified) (5 diffs)
-
lib/Doctrine/Table.php (modified) (1 diff)
-
tests/run.php (modified) (1 diff)
-
tests/Ticket/1254TestCase.php (added)
-
tests/Ticket/1277TestCase.php (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/lib/Doctrine/Record.php
r4770 r4772 515 515 { 516 516 $this->_values = array_merge($this->_values, $this->cleanData($data)); 517 $this->_data = array_merge($this->_data, $data);517 $this->_data = array_merge($this->_data, $data); 518 518 $this->prepareIdentifiers(true); 519 519 } … … 829 829 /** 830 830 * load 831 * loads all the uninitialized properties from the database 831 * Loads all the uninitialized properties from the database. 832 * Used to move a record from PROXY to CLEAN/DIRTY state. 832 833 * 833 834 * @return boolean 834 835 */ 835 public function load( )836 public function load(array $data = array()) 836 837 { 837 838 // only load the data from database if the Doctrine_Record is in proxy state 838 839 if ($this->_state == Doctrine_Record::STATE_PROXY) { 839 $this->refresh(); 840 $this->_state = Doctrine_Record::STATE_CLEAN; 840 $id = $this->identifier(); 841 if ( ! is_array($id)) { 842 $id = array($id); 843 } 844 if (empty($id)) { 845 return false; 846 } 847 848 $data = empty($data) ? $this->getTable()->find($id, Doctrine::HYDRATE_ARRAY) : $data; 849 foreach ($data as $field => $value) { 850 if ( ! isset($this->_data[$field]) || $this->_data[$field] === self::$_null) { 851 $this->_data[$field] = $value; 852 } 853 } 854 855 if ($this->isModified()) { 856 $this->_state = Doctrine_Record::STATE_DIRTY; 857 } else if (count($data) >= $this->_table->getColumnCount()) { 858 $this->_state = Doctrine_Record::STATE_CLEAN; 859 } 860 $this->cleanData($this->_data); 841 861 return true; 842 862 } … … 941 961 if ($this->_isValueModified($type, $old, $value)) { 942 962 if ($value === null) { 943 $default = $this->_table->getDefaultValueOf($fieldName); 963 $default = $this->_table->getDefaultValueOf($fieldName); 944 964 $value = ($default === null) ? self::$_null : $default; 945 965 } 946 947 966 $this->_data[$fieldName] = $value; 948 967 $this->_modified[] = $fieldName; 968 949 969 switch ($this->_state) { 950 970 case Doctrine_Record::STATE_CLEAN: 971 case Doctrine_Record::STATE_PROXY: 951 972 $this->_state = Doctrine_Record::STATE_DIRTY; 952 973 break; … … 1255 1276 } 1256 1277 } 1257 1258 1278 $map = $this->_table->inheritanceMap; 1259 1279 foreach ($map as $k => $v) { … … 1848 1868 foreach ($ids as $id) { 1849 1869 $record = new $modelClassName; 1850 $record[$localFieldName] = $identifier;1870 $record[$localFieldName] = $identifier; 1851 1871 $record[$foreignFieldName] = $id; 1852 1872 $record->save(); -
branches/1.0/lib/Doctrine/Table.php
r4768 r4772 1431 1431 return $record; 1432 1432 } 1433 1434 1433 1435 1434 $id = implode(' ', $id); 1436 1435 1437 1436 if (isset($this->_identityMap[$id])) { 1437 //NOTE: This is still flawed as modifications are overridden in hydrate() 1438 1438 $record = $this->_identityMap[$id]; 1439 1439 $record->hydrate($this->_data); 1440 if ($record->state() == Doctrine_Record::STATE_PROXY) { 1441 if (count($this->_data) >= $this->getColumnCount()) { 1442 $record->state(Doctrine_Record::STATE_CLEAN); 1443 } 1444 } 1440 1445 } else { 1441 1446 $recordName = $this->getComponentName(); -
branches/1.0/tests/run.php
r4770 r4772 102 102 $tickets->addTestCase(new Doctrine_Ticket_1251_TestCase()); 103 103 $tickets->addTestCase(new Doctrine_Ticket_1253_TestCase()); 104 $tickets->addTestCase(new Doctrine_Ticket_1254_TestCase()); 104 105 $tickets->addTestCase(new Doctrine_Ticket_1257_TestCase()); 106 $tickets->addTestCase(new Doctrine_Ticket_1277_TestCase()); 105 107 $tickets->addTestCase(new Doctrine_Ticket_1289_TestCase()); 106 108 $tickets->addTestCase(new Doctrine_Ticket_1296_TestCase());