Changeset 3791

Show
Ignore:
Timestamp:
02/15/08 17:45:10 (17 months ago)
Author:
jwage
Message:

Merging r3787 to 0.10 branch. r3787 was a merge of a few select changes from r3565 which was committed to trunk. This fixes issues with create/drop db functionality for sqlite and a few other misc. fixes.

Location:
branches/0.10
Files:
1 removed
16 modified

Legend:

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

    r3672 r3791  
    809809    public static function createDatabases($specifiedConnections = array()) 
    810810    { 
    811         if ( ! is_array($specifiedConnections)) { 
    812             $specifiedConnections = (array) $specifiedConnections; 
    813         } 
    814  
    815         $manager = Doctrine_Manager::getInstance(); 
    816         $connections = $manager->getConnections(); 
    817  
    818         $results = array(); 
    819  
    820         foreach ($connections as $name => $connection) { 
    821             if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { 
    822                 continue; 
    823             } 
    824  
    825             $info = $manager->parsePdoDsn($connection->getOption('dsn')); 
    826             $username = $connection->getOption('username'); 
    827             $password = $connection->getOption('password'); 
    828  
    829             // Make connection without database specified so we can create it 
    830             $connect = $manager->openConnection(new PDO($info['scheme'] . ':host=' . $info['host'], $username, $password), 'tmp_connection', false); 
    831  
    832             try { 
    833                 // Create database 
    834                 $connect->export->createDatabase($name); 
    835  
    836                 // Close the tmp connection with no database 
    837                 $manager->closeConnection($connect); 
    838  
    839                 // Close original connection 
    840                 $manager->closeConnection($connection); 
    841  
    842                 // Reopen original connection with newly created database 
    843                 $manager->openConnection(new PDO($info['dsn'], $username, $password), $name, true); 
    844  
    845                 $results[$name] = true; 
    846             } catch (Exception $e) { 
    847                 $results[$name] = false; 
    848             } 
    849         } 
    850  
    851         return $results; 
     811        return Doctrine_Manager::getInstance()->createDatabases($specifiedConnections); 
    852812    } 
    853813 
     
    862822    public static function dropDatabases($specifiedConnections = array()) 
    863823    { 
    864         if ( ! is_array($specifiedConnections)) { 
    865             $specifiedConnections = (array) $specifiedConnections; 
    866         } 
    867  
    868         $manager = Doctrine_Manager::getInstance(); 
    869  
    870         $connections = $manager->getConnections(); 
    871  
    872         $results = array(); 
    873  
    874         foreach ($connections as $name => $connection) { 
    875             if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { 
    876                 continue; 
    877             } 
    878  
    879             try { 
    880                 $connection->export->dropDatabase($name); 
    881  
    882                 $results[$name] = true; 
    883             } catch (Exception $e) { 
    884                 $results[$name] = false; 
    885             } 
    886         } 
    887  
    888         return $results; 
     824        return Doctrine_Manager::getInstance()->dropDatabases($specifiedConnections); 
    889825    } 
    890826 
  • branches/0.10/lib/Doctrine/Configurable.php

    r3678 r3791  
    381381    public function getAttribute($attribute) 
    382382    { 
     383        if (is_string($attribute)) { 
     384            $upper = strtoupper($attribute); 
     385 
     386            $const = 'Doctrine::ATTR_' . $upper;  
     387 
     388            if (defined($const)) { 
     389                $attribute = constant($const); 
     390                $this->_state = $attribute; 
     391            } else { 
     392                throw new Doctrine_Exception('Unknown attribute: "' . $attribute . '"'); 
     393            } 
     394        } 
     395 
    383396        $attribute = (int) $attribute; 
    384397 
  • branches/0.10/lib/Doctrine/Connection.php

    r3416 r3791  
    6868 
    6969    /** 
    70      * @var string $driverName                  the name of this connection driver 
     70     * $_name 
     71     * 
     72     * Name of the connection 
     73     * 
     74     * @var string $_name 
     75     */ 
     76    protected $_name; 
     77 
     78    /** 
     79     * The name of this connection driver. 
     80     * 
     81     * @var string $driverName                   
    7182     */ 
    7283    protected $driverName; 
     
    292303    public function getName() 
    293304    { 
     305        return $this->_name; 
     306    } 
     307 
     308    /** 
     309     * setName 
     310     * 
     311     * Sets the name of the connection 
     312     * 
     313     * @param string $name  
     314     * @return void 
     315     */ 
     316    public function setName($name) 
     317    { 
     318        $this->_name = $name; 
     319    } 
     320 
     321    /** 
     322     * getDriverName 
     323     * 
     324     * Gets the name of the instance driver 
     325     * 
     326     * @return void 
     327     */ 
     328    public function getDriverName() 
     329    { 
    294330        return $this->driverName; 
    295331    } 
     
    326362                    break; 
    327363                default: 
    328                     $class = 'Doctrine_' . ucwords($name) . '_' . $this->getName(); 
     364                    $class = 'Doctrine_' . ucwords($name) . '_' . $this->getDriverName(); 
    329365                    $this->modules[$name] = new $class($this); 
    330366                } 
     
    13181354    } 
    13191355 
     1356    public function createDatabase() 
     1357    { 
     1358        try { 
     1359            if ( ! $dsn = $this->getOption('dsn')) { 
     1360                throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); 
     1361            } 
     1362 
     1363            $manager = $this->getManager(); 
     1364 
     1365            $info = $manager->parsePdoDsn($dsn); 
     1366            $username = $this->getOption('username'); 
     1367            $password = $this->getOption('password'); 
     1368 
     1369            // Make connection without database specified so we can create it 
     1370            $connect = $manager->openConnection(new PDO($info['scheme'] . ':host=' . $info['host'], $username, $password), 'tmp_connection', false); 
     1371 
     1372            // Create database 
     1373            $connect->export->createDatabase($info['dbname']); 
     1374 
     1375            // Close the tmp connection with no database 
     1376            $manager->closeConnection($connect); 
     1377 
     1378            // Close original connection 
     1379            $manager->closeConnection($this); 
     1380 
     1381            // Reopen original connection with newly created database 
     1382            $manager->openConnection(new PDO($info['dsn'], $username, $password), $this->getName(), true); 
     1383 
     1384            return 'Successfully created database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"'; 
     1385        } catch (Exception $e) { 
     1386            return $e; 
     1387        } 
     1388    } 
     1389 
     1390    /** 
     1391     * dropDatabase 
     1392     * 
     1393     * Method for dropping the database for the connection instance 
     1394     * 
     1395     * @return mixed Will return an instance of the exception thrown if the drop database fails, otherwise it returns a string detailing the success 
     1396     */ 
     1397    public function dropDatabase() 
     1398    { 
     1399      try { 
     1400          if ( ! $dsn = $this->getOption('dsn')) { 
     1401              throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); 
     1402          } 
     1403 
     1404          $info = $this->getManager()->parsePdoDsn($dsn); 
     1405 
     1406          $this->export->dropDatabase($info['dbname']); 
     1407 
     1408          return 'Successfully dropped database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"'; 
     1409      } catch (Exception $e) { 
     1410          return $e; 
     1411      } 
     1412    } 
     1413 
    13201414    /** 
    13211415     * returns a string representation of this object 
  • branches/0.10/lib/Doctrine/Connection/Sqlite.php

    r3032 r3791  
    9999 
    100100    /** 
    101      * getDatabaseFile 
     101     * createDatabase 
    102102     * 
    103      * @param string $name      the name of the database 
    104      * @return string 
     103     * @return void 
    105104     */ 
    106     public function getDatabaseFile($name) 
     105    public function createDatabase() 
    107106    { 
    108         return $name . '.db'; 
     107      try { 
     108          if ( ! $dsn = $this->getOption('dsn')) { 
     109              throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); 
     110          } 
     111 
     112          $info = $this->getManager()->parseDsn($dsn); 
     113 
     114          $this->export->createDatabase($info['database']); 
     115 
     116          return 'Successfully created database for connection "' . $this->getName() . '" at path "' . $info['database'] . '"'; 
     117      } catch (Exception $e) { 
     118          return $e; 
     119      } 
     120    } 
     121 
     122    /** 
     123     * dropDatabase 
     124     * 
     125     * @return void 
     126     */ 
     127    public function dropDatabase() 
     128    { 
     129      try { 
     130          if ( ! $dsn = $this->getOption('dsn')) { 
     131              throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); 
     132          } 
     133           
     134          $info = $this->getManager()->parseDsn($dsn); 
     135 
     136          $this->export->dropDatabase($info['database']); 
     137 
     138          return 'Successfully dropped database for connection "' . $this->getName() . '" at path "' . $info['database'] . '"'; 
     139      } catch (Exception $e) { 
     140          return $e; 
     141      } 
    109142    } 
    110143} 
  • branches/0.10/lib/Doctrine/Connection/UnitOfWork.php

    r3702 r3791  
    702702            $table->getIdentifierType() != Doctrine::IDENTIFIER_NATURAL) { 
    703703 
    704             if (strtolower($this->conn->getName()) == 'pgsql') { 
     704            if (strtolower($this->conn->getDriverName()) == 'pgsql') { 
    705705                $seq = $table->getTableName() . '_' . $identifier[0]; 
    706706            } 
  • branches/0.10/lib/Doctrine/Export.php

    r3770 r3791  
    10591059     * @return void 
    10601060     */ 
    1061     public function exportClasses(array $classes) 
    1062     { 
    1063         $connections = array(); 
    1064         foreach ($classes as $class) { 
    1065             $record = new $class(); 
    1066             $connection = $record->getTable()->getConnection(); 
    1067             $connectionName = Doctrine_Manager::getInstance()->getConnectionName($connection); 
    1068              
    1069             if ( ! isset($connections[$connectionName])) { 
    1070                 $connections[$connectionName] = array(); 
    1071                 $connections[$connectionName]['creates'] = array(); 
    1072                 $connections[$connectionName]['alters'] = array(); 
    1073             } 
    1074              
    1075             $sql = $this->exportClassesSql(array($class)); 
    1076             // Build array of all the creates 
    1077             // We need these to happen first 
    1078             foreach ($sql as $key => $query) { 
    1079                 if (strstr($query, 'CREATE')) { 
    1080                     $connections[$connectionName]['creates'][] = $query; 
    1081                     // Unset the create from sql so we can have an array of everything else but creates 
    1082                     unset($sql[$key]); 
    1083                 } 
    1084             } 
    1085              
    1086             $connections[$connectionName]['alters'] = array_merge($connections[$connectionName]['alters'], $sql); 
    1087         } 
    1088  
    1089         // Loop over all the sql again to merge the creates and alters in to the same array, but so that the alters are at the bottom 
    1090         $build = array(); 
    1091         foreach ($connections as $connectionName => $sql) { 
    1092             $build[$connectionName] = array_merge($sql['creates'], $sql['alters']); 
    1093         } 
    1094  
    1095         foreach ($build as $connectionName => $sql) { 
    1096             $connection = Doctrine_Manager::getInstance()->getConnection($connectionName); 
    1097              
    1098             $connection->beginTransaction(); 
    1099              
    1100             foreach ($sql as $query) { 
    1101                 try { 
    1102                     $connection->exec($query); 
    1103                 } catch (Doctrine_Connection_Exception $e) { 
    1104                     // we only want to silence table already exists errors 
    1105                     if ($e->getPortableCode() !== Doctrine::ERR_ALREADY_EXISTS) { 
    1106                         $connection->rollback(); 
    1107                         throw new Doctrine_Export_Exception($e->getMessage() . '. Failing Query: ' . $query); 
    1108                     } 
    1109                 } 
    1110             } 
    1111              
    1112             $connection->commit(); 
    1113         } 
    1114     } 
     1061     public function exportClasses(array $classes) 
     1062     {  
     1063         $connections = array(); 
     1064         foreach ($classes as $class) { 
     1065             $record = new $class(); 
     1066             $connection = $record->getTable()->getConnection(); 
     1067             $connectionName = Doctrine_Manager::getInstance()->getConnectionName($connection); 
     1068 
     1069             if ( ! isset($connections[$connectionName])) { 
     1070                 $connections[$connectionName] = array( 
     1071                     'create_tables' => array(), 
     1072                     'create_sequences' => array(), 
     1073                     'alters' => array() 
     1074                 ); 
     1075             } 
     1076 
     1077             $sql = $this->exportClassesSql(array($class)); 
     1078 
     1079             // Build array of all the creates 
     1080             // We need these to happen first 
     1081             foreach ($sql as $key => $query) { 
     1082                 if (strstr($query, 'CREATE TABLE')) { 
     1083                     $connections[$connectionName]['create_tables'][] = $query; 
     1084 
     1085                     unset($sql[$key]); 
     1086                 } 
     1087 
     1088                 if (strstr($query, 'CREATE SEQUENCE')) { 
     1089                     $connections[$connectionName]['create_sequences'][] = $query; 
     1090 
     1091                     unset($sql[$key]); 
     1092                 } 
     1093             } 
     1094 
     1095             $connections[$connectionName]['alters'] = array_merge($connections[$connectionName]['alters'], $sql); 
     1096         } 
     1097 
     1098         // Loop over all the sql again to merge the creates and alters in to the same array, but so that the alters are at the bottom 
     1099         $build = array(); 
     1100         foreach ($connections as $connectionName => $sql) { 
     1101             $build[$connectionName] = array_merge($sql['create_tables'], $sql['create_sequences'], $sql['alters']); 
     1102         } 
     1103 
     1104         foreach ($build as $connectionName => $sql) { 
     1105             $connection = Doctrine_Manager::getInstance()->getConnection($connectionName); 
     1106 
     1107             $connection->beginTransaction(); 
     1108 
     1109             foreach ($sql as $query) { 
     1110                 try { 
     1111                     $connection->exec($query); 
     1112                 } catch (Doctrine_Connection_Exception $e) { 
     1113                     // we only want to silence table already exists errors 
     1114                     if ($e->getPortableCode() !== Doctrine::ERR_ALREADY_EXISTS) { 
     1115                         $connection->rollback(); 
     1116                         throw new Doctrine_Export_Exception($e->getMessage() . '. Failing Query: ' . $query); 
     1117                     } 
     1118                 } 
     1119             } 
     1120 
     1121             $connection->commit(); 
     1122         } 
     1123     } 
    11151124 
    11161125    /** 
  • branches/0.10/lib/Doctrine/Export/Sqlite.php

    r3048 r3791  
    3535{ 
    3636    /** 
     37     * dropDatabase 
     38     * 
    3739     * drop an existing database 
    3840     * 
    39      * @param string $name                  name of the database that should be dropped 
     41     * @param string $databaseFile          Path of the database that should be dropped 
    4042     * @throws Doctrine_Export_Exception    if the database file does not exist 
    4143     * @throws Doctrine_Export_Exception    if something failed during the removal of the database file 
    4244     * @return void 
    4345     */ 
    44     public function dropDatabase($name) 
    45     { 
    46         $databaseFile = $this->conn->getDatabaseFile($name); 
     46    public function dropDatabase($databaseFile) 
     47    { 
    4748        if ( ! @file_exists($databaseFile)) { 
    4849            throw new Doctrine_Export_Exception('database does not exist'); 
    4950        } 
     51 
    5052        $result = @unlink($databaseFile); 
     53 
    5154        if ( ! $result) { 
    5255            throw new Doctrine_Export_Exception('could not remove the database file'); 
    5356        } 
     57    } 
     58 
     59    /** 
     60     * createDatabase 
     61     * 
     62     * Create sqlite database file 
     63     * 
     64     * @param string $databaseFile  Path of the database that should be dropped 
     65     * @return void 
     66     */ 
     67    public function createDatabase($databaseFile) 
     68    { 
     69        return new PDO('sqlite:' . $databaseFile); 
    5470    } 
    5571 
  • branches/0.10/lib/Doctrine/Manager.php

    r3381 r3791  
    257257 
    258258            $driverName = $adapter->getAttribute(Doctrine::ATTR_DRIVER_NAME); 
    259         } elseif (is_array($adapter)) { 
     259        } else if (is_array($adapter)) { 
    260260            if ( ! isset($adapter[0])) { 
    261261                throw new Doctrine_Manager_Exception('Empty data source name given.'); 
     
    271271            $parts['user']   = (isset($adapter[1])) ? $adapter[1] : null; 
    272272            $parts['pass']   = (isset($adapter[2])) ? $adapter[2] : null; 
    273              
     273 
    274274            $driverName = $e[0]; 
    275275            $adapter = $parts; 
    276276        } else { 
    277277            $parts = $this->parseDsn($adapter); 
    278              
    279278            $driverName = $parts['scheme']; 
    280              
    281279            $adapter = $parts; 
    282280        } 
     
    297295            $this->_index++; 
    298296        } 
    299  
    300297 
    301298        $drivers = array('mysql'    => 'Doctrine_Connection_Mysql', 
     
    310307                         'informix' => 'Doctrine_Connection_Informix', 
    311308                         'mock'     => 'Doctrine_Connection_Mock'); 
     309 
    312310        if ( ! isset($drivers[$driverName])) { 
    313311            throw new Doctrine_Manager_Exception('Unknown driver ' . $driverName); 
    314312        } 
    315          
     313 
    316314        $className = $drivers[$driverName]; 
    317315        $conn = new $className($this, $adapter); 
     316        $conn->setName($name); 
    318317 
    319318        $this->_connections[$name] = $conn; 
     
    326325     
    327326    /** 
    328      * parsePdoDsn  
    329      *  
    330      * @param array $dsn An array of dsn information  
     327     * parsePdoDsn 
     328     * 
     329     * @param array $dsn An array of dsn information 
    331330     * @return array The array parsed 
     331     * @todo package:dbal 
    332332     */ 
    333333    public function parsePdoDsn($dsn) 
    334334    { 
    335335        $parts = array(); 
    336          
     336 
    337337        $names = array('dsn', 'scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment'); 
    338338 
     
    342342            } 
    343343        } 
    344          
     344 
    345345        $e = explode(':', $dsn); 
    346346        $parts['scheme'] = $e[0]; 
    347347        $parts['dsn'] = $dsn; 
    348          
     348 
    349349        $e = explode(';', $e[1]); 
    350350        foreach ($e as $string) { 
    351             list($key, $value) = explode('=', $string); 
    352             $parts[$key] = $value; 
    353         } 
    354          
     351            if ($string) { 
     352                $e2 = explode('=', $string); 
     353 
     354                if (isset($e2[0]) && isset($e2[1])) { 
     355                    list($key, $value) = $e2; 
     356                    $parts[$key] = $value; 
     357                } 
     358            } 
     359        } 
     360 
    355361        return $parts; 
    356362    } 
     
    361367     * @param string $dsn 
    362368     * @return array Parsed contents of DSN 
     369     * @todo package:dbal 
    363370     */ 
    364371    public function parseDsn($dsn) 
    365372    { 
    366  
    367  
    368         //fix linux sqlite dsn so that it will parse correctly 
    369         $dsn = str_replace("///", "/", $dsn); 
     373        // fix sqlite dsn so that it will parse correctly 
     374        $dsn = str_replace("////", "/", $dsn); 
     375        $dsn = str_replace("///c:/", "//c:/", $dsn); 
    370376 
    371377        // silence any warnings 
     
    402408 
    403409                break; 
    404              
     410 
    405411            case 'mssql': 
    406412            case 'dblib': 
     
    414420                    throw new Doctrine_Manager_Exception('No hostname set in data source name'); 
    415421                } 
    416                  
     422 
    417423                if (isset(self::$driverMap[$parts['scheme']])) { 
    418424                    $parts['scheme'] = self::$driverMap[$parts['scheme']]; 
     
    422428                              . $parts['host'] . (isset($parts['port']) ? ':' . $parts['port']:null) . ';dbname=' 
    423429                              . $parts['database']; 
    424                  
     430 
    425431                break; 
    426432 
     
    443449                    throw new Doctrine_Manager_Exception('No hostname set in data source name'); 
    444450                } 
    445                  
     451 
    446452                if (isset(self::$driverMap[$parts['scheme']])) { 
    447453                    $parts['scheme'] = self::$driverMap[$parts['scheme']]; 
     
    451457                              . $parts['host'] . (isset($parts['port']) ? ';port=' . $parts['port']:null) . ';dbname=' 
    452458                              . $parts['database']; 
    453                  
     459 
    454460                break; 
    455461            default: 
    456462                throw new Doctrine_Manager_Exception('Unknown driver '.$parts['scheme']); 
    457463        } 
    458  
    459464 
    460465        return $parts; 
     
    687692        } 
    688693        return $this->_connections[$i]; 
     694    } 
     695 
     696    /** 
     697     * createDatabases 
     698     * 
     699     * Creates databases for connections 
     700     * 
     701     * @param string $specifiedConnections Array of connections you wish to create the database for 
     702     * @return void 
     703     * @todo package:dbal 
     704     */ 
     705    public function createDatabases($specifiedConnections = array()) 
     706    { 
     707        if ( ! is_array($specifiedConnections)) { 
     708            $specifiedConnections = (array) $specifiedConnections; 
     709        } 
     710 
     711        $results = array(); 
     712 
     713        foreach ($this as $name => $connection) { 
     714            if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { 
     715                continue; 
     716            } 
     717 
     718            $results[$name] = $connection->createDatabase(); 
     719        } 
     720 
     721        return $results; 
     722    } 
     723 
     724    /** 
     725     * dropDatabases 
     726     * 
     727     * Drops databases for connections 
     728     * 
     729     * @param string $specifiedConnections Array of connections you wish to drop the database for 
     730     * @return void 
     731     * @todo package:dbal 
     732     */ 
     733    public function dropDatabases($specifiedConnections = array()) 
     734    { 
     735        if ( ! is_array($specifiedConnections)) { 
     736            $specifiedConnections = (array) $specifiedConnections; 
     737        } 
     738 
     739        $results = array(); 
     740 
     741        foreach ($this as $name => $connection) { 
     742            if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { 
     743                continue; 
     744            } 
     745 
     746            $results[$name] = $connection->dropDatabase(); 
     747        } 
     748 
     749        return $results; 
    689750    } 
    690751 
  • branches/0.10/lib/Doctrine/Query.php

    r3789 r3791  
    11751175                // what about composite keys? 
    11761176                $idColumnName = $table->getColumnName($table->getIdentifier()); 
    1177                 switch (strtolower($this->_conn->getName())) { 
     1177                switch (strtolower($this->_conn->getDriverName())) { 
    11781178                    case 'mysql': 
    11791179                        // mysql doesn't support LIMIT in subqueries 
  • branches/0.10/lib/Doctrine/Query/Tokenizer.php

    r3313 r3791  
    378378            } 
    379379        } 
    380         $term[$i - 1] = array($term[$i - 1], ''); 
     380 
     381        if (isset($term[$i - 1])) { 
     382            $term[$i - 1] = array($term[$i - 1], ''); 
     383        } 
    381384 
    382385        return $term; 
  • branches/0.10/lib/Doctrine/Task/CreateDb.php

    r3130 r3791  
    4040        $results = Doctrine::createDatabases(); 
    4141         
    42         foreach ($results as $dbName => $bool) { 
    43             $msg = $bool ? 'Successfully created database named: "' . $dbName . '"':'Could not create database named: "' .$dbName . '"'; 
     42        foreach ($results as $name => $result) { 
     43            $msg = $result instanceof Exception ? 'Could not create database for connection: "' .$name . '." Failed with exception: ' . $result->getMessage():$result; 
    4444             
    4545            $this->notify($msg); 
  • branches/0.10/lib/Doctrine/Task/DropDb.php

    r3679 r3791  
    5151        $results = Doctrine::dropDatabases(); 
    5252 
    53         foreach ($results as $dbName => $bool) { 
    54             $msg = $bool ? 'Successfully dropped database named: "' . $dbName . '"':'Could not drop database named: "' .$dbName . '"'; 
     53        foreach ($results as $name => $result) { 
     54            $msg = $result instanceof Exception ? 'Could not drop database for connection: "' .$name . '." Failed with exception: ' . $result->getMessage():$result; 
    5555 
    5656            $this->notify($msg); 
  • branches/0.10/tests/Export/SqliteTestCase.php

    r2963 r3791  
    3333class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase  
    3434{ 
    35     public function testCreateDatabaseDoesNotExecuteSql()  
     35    public function testCreateDatabaseDoesNotExecuteSqlAndCreatesSqliteFile() 
    3636    { 
    37         try { 
    38             $this->export->createDatabase('db'); 
    39             $this->fail(); 
    40         } catch(Doctrine_Export_Exception $e) { 
    41             $this->pass(); 
    42         } 
     37        $this->export->createDatabase('sqlite.db'); 
     38       
     39        $this->assertTrue(file_exists('sqlite.db')); 
    4340    } 
    44     public function testDropDatabaseDoesNotExecuteSql()  
     41    public function testDropDatabaseDoesNotExecuteSqlAndDeletesSqliteFile() 
    4542    { 
    46         try { 
    47             $this->export->dropDatabase('db'); 
    48             $this->fail(); 
    49         } catch(Doctrine_Export_Exception $e) { 
    50             $this->pass(); 
    51         } 
     43        $this->export->dropDatabase('sqlite.db'); 
     44 
     45        $this->assertFalse(file_exists('sqlite.db')); 
    5246    } 
    5347    public function testCreateTableSupportsAutoincPks()  
  • branches/0.10/tests/ManagerTestCase.php

    r3071 r3791  
    6666        // It expects only // since it thinks it is parsing a url 
    6767        // The problem after that is that the dns is not valid when being passed to PDO 
    68         $sqlite = 'sqlite:///full/unix/path/to/file.db'; 
    69         $sqlitewin = 'sqlite://c:/full/windows/path/to/file.db'; 
     68        $sqlite = 'sqlite:////full/unix/path/to/file.db'; 
     69        $sqlitewin = 'sqlite:///c:/full/windows/path/to/file.db'; 
    7070         
    7171        $manager = Doctrine_Manager::getInstance(); 
  • branches/0.10/tests/TreeStructureTestCase.php

    r2353 r3791  
    104104        $o4->save(); 
    105105 
    106         $o1->Children; 
    107106        $this->assertFalse(isset($o1->Parent)); 
     107        $this->assertTrue(isset($o2->Parent)); 
     108        $this->assertTrue($o2->Parent === $o1); 
     109        $this->assertFalse(isset($o4->Parent)); 
     110       
    108111        $this->assertTrue(count($o1->Children) == 2); 
    109112        $this->assertTrue(count($o1->get('Children')) == 2); 
    110113 
    111         $this->assertTrue(isset($o2->Parent)); 
    112         $this->assertTrue($o2->Parent === $o1); 
    113  
    114114        $this->assertTrue(count($o4->Children) == 0); 
    115         $this->assertFalse(isset($o4->Parent)); 
    116115    } 
    117116    public function testTreeStructureFetchingWorksWithDql() 
  • branches/0.10/tools/sandbox/config.php.dist

    r3415 r3791  
    4343define('YAML_SCHEMA_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'schema'); 
    4444define('DB_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'sandbox.db'); 
    45 define('DSN', 'sqlite:' . DB_PATH); 
     45define('DSN', 'sqlite:///' . DB_PATH); 
    4646 
    4747require_once(DOCTRINE_PATH . DIRECTORY_SEPARATOR . 'Doctrine.php'); 
     
    4949spl_autoload_register(array('Doctrine', 'autoload')); 
    5050 
    51 $pdo = new PDO(DSN); 
    52 Doctrine_Manager::connection($pdo, 'sandbox'); 
     51Doctrine_Manager::connection(DSN, 'sandbox'); 
    5352 
    54 Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE); 
     53Doctrine_Manager::getInstance()->setAttribute('model_loading', 'conservative');