Changeset 3975

Show
Ignore:
Timestamp:
03/13/08 02:16:21 (16 months ago)
Author:
jwage
Message:

fixed #691 fixes #750

Location:
branches/0.10
Files:
18 modified

Legend:

Unmodified
Added
Removed
  • branches/0.10/lib/Doctrine/Access.php

    r3884 r3975  
    1919 * <http://www.phpdoctrine.org>. 
    2020 */ 
    21  
     21Doctrine::autoload('Doctrine_Locator_Injectable'); 
    2222/** 
    2323 * Doctrine_Access 
  • branches/0.10/lib/Doctrine/AuditLog.php

    r3954 r3975  
    1919 * <http://www.phpdoctrine.org>. 
    2020 */ 
    21  
     21Doctrine::autoload('Doctrine_Record_Generator'); 
    2222/** 
    2323 * Doctrine_AuditLog 
  • branches/0.10/lib/Doctrine/Column.php

    r3884 r3975  
    1919 * <http://www.phpdoctrine.org>. 
    2020 */ 
    21  
     21Doctrine::autoload('Doctrine_Access'); 
    2222/** 
    2323 * Doctrine_Column 
  • branches/0.10/lib/Doctrine/Connection.php

    r3969 r3975  
    13781378    } 
    13791379 
     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     */ 
    13801387    public function createDatabase() 
    13811388    { 
     
    13951402        } catch (Exception $e) {} 
    13961403 
    1397         // Close the temporary connection used to issue the drop database command 
    1398         $this->getManager()->closeConnection($tmpConnection); 
    1399  
    1400         // Re-create Doctrine style dsn 
    1401         $dsn = $info['scheme'] . '://' . $this->getOption('username') . ':' . $this->getOption('password') . '@' . $info['host'] . '/' . $info['dbname']; 
    1402  
    1403         // Re-open connection with the newly created database 
    1404         $this->getManager()->openConnection($dsn, $this->getName(), true); 
    1405  
    14061404        if (isset($e)) { 
    14071405            return $e; 
    14081406        } 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 
    14091416            return 'Successfully created database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"'; 
    14101417        } 
     
    14141421     * dropDatabase 
    14151422     * 
    1416      * Method for dropping the database for the connection instance 
    1417      * 
    1418      * @return mixed Will return an instance of the exception thrown if the drop database fails, otherwise it returns a string detailing the success 
     1423     * Issue drop database command for this instance of Doctrine_Connection 
     1424     * 
     1425     * @return mixed Returns Doctrine_Exception or success string 
    14191426     */ 
    14201427    public function dropDatabase() 
     
    14351442        } catch (Exception $e) {} 
    14361443 
    1437         // Close the temporary connection used to issue the drop database command 
    1438         $this->getManager()->closeConnection($tmpConnection); 
    1439  
    1440         // Re-create Doctrine style dsn 
    1441         $dsn = $info['scheme'] . '://' . $this->getOption('username') . ':' . $this->getOption('password') . '@' . $info['host'] . '/' . $info['dbname']; 
    1442  
    1443         // Re-open connection with the newly created database 
    1444         $this->getManager()->openConnection($dsn, $this->getName(), true); 
    1445  
    14461444        if (isset($e)) { 
    14471445            return $e; 
    14481446        } 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 
    14491456            return 'Successfully dropped database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"'; 
    14501457        } 
     
    14531460    /** 
    14541461     * 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 
    14551468     * 
    14561469     * @param string $info  
  • branches/0.10/lib/Doctrine/Connection/UnitOfWork.php

    r3892 r3975  
    179179            } 
    180180 
     181            foreach ($record->getPendingDeletes() as $pendingDelete) { 
     182                $pendingDelete->delete(); 
     183            } 
     184 
    181185            $record->getTable()->getRecordListener()->postSave($event); 
    182186              
  • branches/0.10/lib/Doctrine/DataDict.php

    r3884 r3975  
    1919 * <http://www.phpdoctrine.org>. 
    2020 */ 
    21  
     21Doctrine::autoload('Doctrine_Connection_Module'); 
    2222/** 
    2323 * Doctrine_DataDict 
  • branches/0.10/lib/Doctrine/Expression.php

    r3884 r3975  
    1919 * <http://www.phpdoctrine.org>. 
    2020 */ 
    21 Doctrine::autoload('Doctrine_Connection_Module'); 
     21 
    2222/** 
    2323 * Doctrine_Expression 
  • branches/0.10/lib/Doctrine/File.php

    r3884 r3975  
    1919 * <http://www.phpdoctrine.org>. 
    2020 */ 
    21  
     21Doctrine::autoload('Doctrine_Record'); 
    2222/** 
    2323 * Doctrine_File 
  • branches/0.10/lib/Doctrine/Hydrator.php

    r3944 r3975  
    1919 * <http://www.phpdoctrine.org>. 
    2020 */ 
    21  
     21Doctrine::autoload('Doctrine_Hydrator_Abstract'); 
    2222/** 
    2323 * Doctrine_Hydrate is a base class for Doctrine_RawSql and Doctrine_Query. 
  • branches/0.10/lib/Doctrine/I18n.php

    r3914 r3975  
    1919 * <http://www.phpdoctrine.org>. 
    2020 */ 
    21  
     21Doctrine::autoload('Doctrine_Record_Generator'); 
    2222/** 
    2323 * Doctrine_I18n 
  • branches/0.10/lib/Doctrine/Import/Schema.php

    r3966 r3975  
    484484        foreach($this->_relations as $className => $relations) { 
    485485            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)) { 
    487487                    continue; 
    488488                } 
  • branches/0.10/lib/Doctrine/Query/Abstract.php

    r3958 r3975  
    236236    protected $_isLimitSubqueryUsed = false; 
    237237     
     238    protected $_pendingSetParams = array(); 
    238239     
    239240    /** 
     
    511512    public function convertEnums($params) 
    512513    { 
     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 
    513524        foreach ($this->_enumParams as $key => $values) { 
    514525            if (isset($params[$key])) { 
     
    12641275                } 
    12651276            } 
     1277 
     1278            $this->_pendingSetParams[$key] = $value; 
     1279 
    12661280            return $this->_addDqlQueryPart('set', $key . ' = ' . $value, true); 
    12671281        } 
  • branches/0.10/lib/Doctrine/Record.php

    r3954 r3975  
    122122 
    123123    /** 
     124     * Doctrine_Collection of objects needing to be deleted on save 
     125     * 
     126     * @var string 
     127     */ 
     128    protected $_pendingDeletes = array(); 
     129 
     130    /** 
    124131     * @var integer $index                  this index is used for creating object identifiers 
    125132     */ 
     
    911918                foreach ($this->_table->getFilters() as $filter) { 
    912919                    if (($value = $filter->filterSet($this, $fieldName, $value)) !== null) { 
    913                         return $value; 
     920                        break; 
    914921                    } 
    915922                } 
    916923            } 
    917924        } 
     925 
     926        return $this; 
    918927    } 
    919928 
     
    9991008     * @return void 
    10001009     */ 
    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; 
    10131033    } 
    10141034 
  • branches/0.10/lib/Doctrine/Search.php

    r3884 r3975  
    1919 * <http://www.phpdoctrine.org>. 
    2020 */ 
    21  
     21Doctrine::autoload('Doctrine_Record_Generator'); 
    2222/** 
    2323 * Doctrine_Search 
  • branches/0.10/lib/Doctrine/Table.php

    r3959 r3975  
    1919 * <http://www.phpdoctrine.org>. 
    2020 */ 
    21  
     21Doctrine::autoload('Doctrine_Configurable'); 
    2222/** 
    2323 * Doctrine_Table   represents a database table 
  • branches/0.10/lib/Doctrine/Tree.php

    r3884 r3975  
    1818 * and is licensed under the LGPL. For more information, see 
    1919 * <http://www.phpdoctrine.org>. 
    20  */                    
     20 */ 
     21                  
    2122/** 
    2223 * Doctrine_Tree 
  • branches/0.10/lib/Doctrine/Validator.php

    r3884 r3975  
    2222/** 
    2323 * Doctrine_Validator 
     24 * 
    2425 * Doctrine_Validator performs validations in record properties 
    2526 * 
  • branches/0.10/tests/ManagerTestCase.php

    r3884 r3975  
    126126        } 
    127127    } 
     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     
    128150    public function prepareData() { } 
    129151    public function prepareTables() { }