1 | <?php |
||
2 | |||
3 | namespace Doctrine\DBAL\Driver; |
||
4 | |||
5 | use Doctrine\DBAL\Connection; |
||
0 ignored issues
–
show
|
|||
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 | 361 | public function convertException($message, DriverException $exception) |
|
21 | { |
||
22 | 361 | switch ($exception->getErrorCode()) { |
|
23 | 361 | case '1': |
|
24 | 357 | case '2299': |
|
25 | 357 | case '38911': |
|
26 | 85 | return new Exception\UniqueConstraintViolationException($message, $exception); |
|
27 | |||
28 | 357 | case '904': |
|
29 | 83 | return new Exception\InvalidFieldNameException($message, $exception); |
|
30 | |||
31 | 355 | case '918': |
|
32 | 353 | case '960': |
|
33 | 83 | return new Exception\NonUniqueFieldNameException($message, $exception); |
|
34 | |||
35 | 353 | case '923': |
|
36 | 83 | return new Exception\SyntaxErrorException($message, $exception); |
|
37 | |||
38 | 351 | case '942': |
|
39 | 201 | return new Exception\TableNotFoundException($message, $exception); |
|
40 | |||
41 | 349 | case '955': |
|
42 | 124 | return new Exception\TableExistsException($message, $exception); |
|
43 | |||
44 | 307 | case '1017': |
|
45 | 303 | case '12545': |
|
46 | 87 | return new Exception\ConnectionException($message, $exception); |
|
47 | |||
48 | 301 | case '1400': |
|
49 | 83 | return new Exception\NotNullConstraintViolationException($message, $exception); |
|
50 | |||
51 | 299 | case '2266': |
|
52 | 299 | case '2291': |
|
53 | 299 | case '2292': |
|
54 | 89 | return new Exception\ForeignKeyConstraintViolationException($message, $exception); |
|
55 | } |
||
56 | |||
57 | 299 | return new Exception\DriverException($message, $exception); |
|
58 | } |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | 254 | public function getDatabase(Connection $conn) |
|
64 | { |
||
65 | 254 | $params = $conn->getParams(); |
|
66 | |||
67 | 254 | return $params['user']; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | 136 | public function getDatabasePlatform() |
|
74 | { |
||
75 | 136 | return new OraclePlatform(); |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | 100 | public function getSchemaManager(Connection $conn) |
|
82 | { |
||
83 | 100 | 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 | 62 | protected function getEasyConnectString(array $params) |
|
94 | { |
||
95 | 62 | return (string) EasyConnectString::fromConnectionParameters($params); |
|
96 | } |
||
97 | } |
||
98 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are 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.php
However, as
OtherDir/Foo.php
does 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: