| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Doctrine\DBAL\Driver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Doctrine\DBAL\Connection; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Doctrine\DBAL\Driver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Doctrine\DBAL\Exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Doctrine\DBAL\Platforms\OraclePlatform; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Doctrine\DBAL\Schema\OracleSchemaManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for Oracle based drivers. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  | abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 | 75 |  |     public function convertException($message, DriverException $exception) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 | 75 |  |         switch ($exception->getErrorCode()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 | 75 |  |             case '1': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 75 |  |             case '2299': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 | 75 |  |             case '38911': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 | 75 |  |                 return new Exception\UniqueConstraintViolationException($message, $exception); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 | 75 |  |             case '904': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 75 |  |                 return new Exception\InvalidFieldNameException($message, $exception); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 75 |  |             case '918': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 | 75 |  |             case '960': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 | 75 |  |                 return new Exception\NonUniqueFieldNameException($message, $exception); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 75 |  |             case '923': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 75 |  |                 return new Exception\SyntaxErrorException($message, $exception); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 75 |  |             case '942': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 75 |  |                 return new Exception\TableNotFoundException($message, $exception); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 75 |  |             case '955': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 75 |  |                 return new Exception\TableExistsException($message, $exception); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 75 |  |             case '1017': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 75 |  |             case '12545': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 75 |  |                 return new Exception\ConnectionException($message, $exception); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 75 |  |             case '1400': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 75 |  |                 return new Exception\NotNullConstraintViolationException($message, $exception); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 75 |  |             case '2266': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 75 |  |             case '2291': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 75 |  |             case '2292': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 75 |  |                 return new Exception\ForeignKeyConstraintViolationException($message, $exception); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 57 | 75 |  |         return new Exception\DriverException($message, $exception); | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 63 | 150 |  |     public function getDatabase(Connection $conn) | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 65 | 150 |  |         $params = $conn->getParams(); | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 67 | 150 |  |         return $params['user']; | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 73 | 75 |  |     public function getDatabasePlatform() | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 75 | 75 |  |         return new OraclePlatform(); | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 | 75 |  |     public function getSchemaManager(Connection $conn) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 83 | 75 |  |         return new OracleSchemaManager($conn); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 84 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |      * Returns an appropriate Easy Connect String for the given parameters. | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |      * @param mixed[] $params The connection parameters to return the Easy Connect String for. | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     protected function getEasyConnectString(array $params) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 95 |  |  |         return (string) EasyConnectString::fromConnectionParameters($params); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 96 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 97 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 98 |  |  |  | 
            
                        
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: