Changeset 3975
- Timestamp:
- 03/13/08 02:16:21 (16 months ago)
- Location:
- branches/0.10
- Files:
-
- 18 modified
-
lib/Doctrine/Access.php (modified) (1 diff)
-
lib/Doctrine/AuditLog.php (modified) (1 diff)
-
lib/Doctrine/Column.php (modified) (1 diff)
-
lib/Doctrine/Connection.php (modified) (5 diffs)
-
lib/Doctrine/Connection/UnitOfWork.php (modified) (1 diff)
-
lib/Doctrine/DataDict.php (modified) (1 diff)
-
lib/Doctrine/Expression.php (modified) (1 diff)
-
lib/Doctrine/File.php (modified) (1 diff)
-
lib/Doctrine/Hydrator.php (modified) (1 diff)
-
lib/Doctrine/I18n.php (modified) (1 diff)
-
lib/Doctrine/Import/Schema.php (modified) (1 diff)
-
lib/Doctrine/Query/Abstract.php (modified) (3 diffs)
-
lib/Doctrine/Record.php (modified) (3 diffs)
-
lib/Doctrine/Search.php (modified) (1 diff)
-
lib/Doctrine/Table.php (modified) (1 diff)
-
lib/Doctrine/Tree.php (modified) (1 diff)
-
lib/Doctrine/Validator.php (modified) (1 diff)
-
tests/ManagerTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine/Access.php
r3884 r3975 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 21 Doctrine::autoload('Doctrine_Locator_Injectable'); 22 22 /** 23 23 * Doctrine_Access -
branches/0.10/lib/Doctrine/AuditLog.php
r3954 r3975 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 21 Doctrine::autoload('Doctrine_Record_Generator'); 22 22 /** 23 23 * Doctrine_AuditLog -
branches/0.10/lib/Doctrine/Column.php
r3884 r3975 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 21 Doctrine::autoload('Doctrine_Access'); 22 22 /** 23 23 * Doctrine_Column -
branches/0.10/lib/Doctrine/Connection.php
r3969 r3975 1378 1378 } 1379 1379 1380 /** 1381 * createDatabase 1382 * 1383 * Issue create database command for this instance of Doctrine_Connection 1384 * 1385 * @return mixed Returns Doctrine_Exception or success string 1386 */ 1380 1387 public function createDatabase() 1381 1388 { … … 1395 1402 } catch (Exception $e) {} 1396 1403 1397 // Close the temporary connection used to issue the drop database command1398 $this->getManager()->closeConnection($tmpConnection);1399 1400 // Re-create Doctrine style dsn1401 $dsn = $info['scheme'] . '://' . $this->getOption('username') . ':' . $this->getOption('password') . '@' . $info['host'] . '/' . $info['dbname'];1402 1403 // Re-open connection with the newly created database1404 $this->getManager()->openConnection($dsn, $this->getName(), true);1405 1406 1404 if (isset($e)) { 1407 1405 return $e; 1408 1406 } else { 1407 // Close the temporary connection used to issue the drop database command 1408 $this->getManager()->closeConnection($tmpConnection); 1409 1410 // Re-create Doctrine style dsn 1411 $dsn = $info['scheme'] . '://' . $this->getOption('username') . ':' . $this->getOption('password') . '@' . $info['host'] . '/' . $info['dbname']; 1412 1413 // Re-open connection with the newly created database 1414 $this->getManager()->openConnection($dsn, $this->getName(), true); 1415 1409 1416 return 'Successfully created database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"'; 1410 1417 } … … 1414 1421 * dropDatabase 1415 1422 * 1416 * Method for dropping the database for the connection instance1417 * 1418 * @return mixed Will return an instance of the exception thrown if the drop database fails, otherwise it returns a string detailing the success1423 * Issue drop database command for this instance of Doctrine_Connection 1424 * 1425 * @return mixed Returns Doctrine_Exception or success string 1419 1426 */ 1420 1427 public function dropDatabase() … … 1435 1442 } catch (Exception $e) {} 1436 1443 1437 // Close the temporary connection used to issue the drop database command1438 $this->getManager()->closeConnection($tmpConnection);1439 1440 // Re-create Doctrine style dsn1441 $dsn = $info['scheme'] . '://' . $this->getOption('username') . ':' . $this->getOption('password') . '@' . $info['host'] . '/' . $info['dbname'];1442 1443 // Re-open connection with the newly created database1444 $this->getManager()->openConnection($dsn, $this->getName(), true);1445 1446 1444 if (isset($e)) { 1447 1445 return $e; 1448 1446 } else { 1447 // Close the temporary connection used to issue the drop database command 1448 $this->getManager()->closeConnection($tmpConnection); 1449 1450 // Re-create Doctrine style dsn 1451 $dsn = $info['scheme'] . '://' . $this->getOption('username') . ':' . $this->getOption('password') . '@' . $info['host'] . '/' . $info['dbname']; 1452 1453 // Re-open connection with the newly created database 1454 $this->getManager()->openConnection($dsn, $this->getName(), true); 1455 1449 1456 return 'Successfully dropped database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"'; 1450 1457 } … … 1453 1460 /** 1454 1461 * getTmpConnection 1462 * 1463 * Create a temporary connection to the database with the user credentials. 1464 * This is so the user can make a connection to a db server. Some dbms allow 1465 * connections with no database, but some do not. In that case we have a table 1466 * which is always guaranteed to exist. Mysql: 'mysql', PostgreSQL: 'postgres', etc. 1467 * This value is set in the Doctrine_Export_{DRIVER} classes if required 1455 1468 * 1456 1469 * @param string $info -
branches/0.10/lib/Doctrine/Connection/UnitOfWork.php
r3892 r3975 179 179 } 180 180 181 foreach ($record->getPendingDeletes() as $pendingDelete) { 182 $pendingDelete->delete(); 183 } 184 181 185 $record->getTable()->getRecordListener()->postSave($event); 182 186 -
branches/0.10/lib/Doctrine/DataDict.php
r3884 r3975 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 21 Doctrine::autoload('Doctrine_Connection_Module'); 22 22 /** 23 23 * Doctrine_DataDict -
branches/0.10/lib/Doctrine/Expression.php
r3884 r3975 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 Doctrine::autoload('Doctrine_Connection_Module'); 21 22 22 /** 23 23 * Doctrine_Expression -
branches/0.10/lib/Doctrine/File.php
r3884 r3975 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 21 Doctrine::autoload('Doctrine_Record'); 22 22 /** 23 23 * Doctrine_File -
branches/0.10/lib/Doctrine/Hydrator.php
r3944 r3975 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 21 Doctrine::autoload('Doctrine_Hydrator_Abstract'); 22 22 /** 23 23 * Doctrine_Hydrate is a base class for Doctrine_RawSql and Doctrine_Query. -
branches/0.10/lib/Doctrine/I18n.php
r3914 r3975 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 21 Doctrine::autoload('Doctrine_Record_Generator'); 22 22 /** 23 23 * Doctrine_I18n -
branches/0.10/lib/Doctrine/Import/Schema.php
r3966 r3975 484 484 foreach($this->_relations as $className => $relations) { 485 485 foreach ($relations AS $alias => $relation) { 486 if ((isset($relation['equal']) && $relation['equal']) || (isset($relation['auto _complete']) && $relation['auto_complete'] === false)) {486 if ((isset($relation['equal']) && $relation['equal']) || (isset($relation['autoComplete']) && $relation['autoComplete'] === false)) { 487 487 continue; 488 488 } -
branches/0.10/lib/Doctrine/Query/Abstract.php
r3958 r3975 236 236 protected $_isLimitSubqueryUsed = false; 237 237 238 protected $_pendingSetParams = array(); 238 239 239 240 /** … … 511 512 public function convertEnums($params) 512 513 { 514 $table = $this->getRoot(); 515 foreach ($this->_pendingSetParams as $fieldName => $value) { 516 $e = explode('.', $fieldName); 517 $fieldName = isset($e[1]) ? $e[1]:$e[0]; 518 $columnName = $table->getColumnName($fieldName); 519 if ($table->getTypeOf($columnName) == 'enum') { 520 $this->addEnumParam($value, $table, $columnName); 521 } 522 } 523 513 524 foreach ($this->_enumParams as $key => $values) { 514 525 if (isset($params[$key])) { … … 1264 1275 } 1265 1276 } 1277 1278 $this->_pendingSetParams[$key] = $value; 1279 1266 1280 return $this->_addDqlQueryPart('set', $key . ' = ' . $value, true); 1267 1281 } -
branches/0.10/lib/Doctrine/Record.php
r3954 r3975 122 122 123 123 /** 124 * Doctrine_Collection of objects needing to be deleted on save 125 * 126 * @var string 127 */ 128 protected $_pendingDeletes = array(); 129 130 /** 124 131 * @var integer $index this index is used for creating object identifiers 125 132 */ … … 911 918 foreach ($this->_table->getFilters() as $filter) { 912 919 if (($value = $filter->filterSet($this, $fieldName, $value)) !== null) { 913 return $value;920 break; 914 921 } 915 922 } 916 923 } 917 924 } 925 926 return $this; 918 927 } 919 928 … … 999 1008 * @return void 1000 1009 */ 1001 public function __unset($fieldName) 1002 { 1003 if (isset($this->_data[$fieldName])) { 1004 $this->_data[$fieldName] = array(); 1005 } else if (isset($this->_references[$fieldName])) { 1006 if ($this->_references[$fieldName] instanceof Doctrine_Record) { 1007 // todo: delete related record when saving $this 1008 $this->_references[$fieldName] = self::$_null; 1009 } elseif ($this->_references[$fieldName] instanceof Doctrine_Collection) { 1010 $this->_references[$fieldName]->setData(array()); 1011 } 1012 } 1010 public function __unset($name) 1011 { 1012 if (isset($this->_data[$name])) { 1013 $this->_data[$name] = array(); 1014 } else if (isset($this->_references[$name])) { 1015 if ($this->_references[$name] instanceof Doctrine_Record) { 1016 $this->_pendingDeletes[] = $this->$name; 1017 $this->_references[$name] = self::$_null; 1018 } elseif ($this->_references[$name] instanceof Doctrine_Collection) { 1019 $this->_pendingDeletes[] = $this->$name; 1020 $this->_references[$name]->setData(array()); 1021 } 1022 } 1023 } 1024 1025 /** 1026 * getPendingDeletes 1027 * 1028 * @return array Array of Doctrine_Records instances which need to be deleted on save 1029 */ 1030 public function getPendingDeletes() 1031 { 1032 return $this->_pendingDeletes; 1013 1033 } 1014 1034 -
branches/0.10/lib/Doctrine/Search.php
r3884 r3975 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 21 Doctrine::autoload('Doctrine_Record_Generator'); 22 22 /** 23 23 * Doctrine_Search -
branches/0.10/lib/Doctrine/Table.php
r3959 r3975 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 21 Doctrine::autoload('Doctrine_Configurable'); 22 22 /** 23 23 * Doctrine_Table represents a database table -
branches/0.10/lib/Doctrine/Tree.php
r3884 r3975 18 18 * and is licensed under the LGPL. For more information, see 19 19 * <http://www.phpdoctrine.org>. 20 */ 20 */ 21 21 22 /** 22 23 * Doctrine_Tree -
branches/0.10/lib/Doctrine/Validator.php
r3884 r3975 22 22 /** 23 23 * Doctrine_Validator 24 * 24 25 * Doctrine_Validator performs validations in record properties 25 26 * -
branches/0.10/tests/ManagerTestCase.php
r3884 r3975 126 126 } 127 127 } 128 129 public function testCreateDatabases() 130 { 131 $this->conn1 = Doctrine_Manager::connection('sqlite:////tmp/doctrine1.db', 'doctrine1'); 132 $this->conn2 = Doctrine_Manager::connection('sqlite:////tmp/doctrine2.db', 'doctrine2'); 133 134 $result1 = $this->conn1->createDatabase(); 135 $this->assertEqual($result1, 'Successfully created database for connection "doctrine1" at path "/tmp/doctrine1.db"'); 136 137 $result2 = $this->conn2->createDatabase(); 138 $this->assertEqual($result2, 'Successfully created database for connection "doctrine2" at path "/tmp/doctrine2.db"'); 139 } 140 141 public function testDropDatabases() 142 { 143 $result1 = $this->conn1->dropDatabase(); 144 $this->assertEqual($result1, 'Successfully dropped database for connection "doctrine1" at path "/tmp/doctrine1.db"'); 145 146 $result2 = $this->conn2->dropDatabase(); 147 $this->assertEqual($result2, 'Successfully dropped database for connection "doctrine2" at path "/tmp/doctrine2.db"'); 148 } 149 128 150 public function prepareData() { } 129 151 public function prepareTables() { }