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
|
561 |
|
public function convertException($message, DriverException $exception) |
21
|
|
|
{ |
22
|
561 |
|
switch ($exception->getErrorCode()) { |
23
|
561 |
|
case '1': |
24
|
557 |
|
case '2299': |
25
|
557 |
|
case '38911': |
26
|
285 |
|
return new Exception\UniqueConstraintViolationException($message, $exception); |
27
|
|
|
|
28
|
557 |
|
case '904': |
29
|
283 |
|
return new Exception\InvalidFieldNameException($message, $exception); |
30
|
|
|
|
31
|
555 |
|
case '918': |
32
|
553 |
|
case '960': |
33
|
283 |
|
return new Exception\NonUniqueFieldNameException($message, $exception); |
34
|
|
|
|
35
|
553 |
|
case '923': |
36
|
283 |
|
return new Exception\SyntaxErrorException($message, $exception); |
37
|
|
|
|
38
|
551 |
|
case '942': |
39
|
401 |
|
return new Exception\TableNotFoundException($message, $exception); |
40
|
|
|
|
41
|
549 |
|
case '955': |
42
|
324 |
|
return new Exception\TableExistsException($message, $exception); |
43
|
|
|
|
44
|
507 |
|
case '1017': |
45
|
503 |
|
case '12545': |
46
|
287 |
|
return new Exception\ConnectionException($message, $exception); |
47
|
|
|
|
48
|
501 |
|
case '1400': |
49
|
283 |
|
return new Exception\NotNullConstraintViolationException($message, $exception); |
50
|
|
|
|
51
|
499 |
|
case '2266': |
52
|
499 |
|
case '2291': |
53
|
499 |
|
case '2292': |
54
|
289 |
|
return new Exception\ForeignKeyConstraintViolationException($message, $exception); |
55
|
|
|
} |
56
|
|
|
|
57
|
499 |
|
return new Exception\DriverException($message, $exception); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
429 |
|
public function getDatabase(Connection $conn) |
64
|
|
|
{ |
65
|
429 |
|
$params = $conn->getParams(); |
66
|
|
|
|
67
|
429 |
|
return $params['user']; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
296 |
|
public function getDatabasePlatform() |
74
|
|
|
{ |
75
|
296 |
|
return new OraclePlatform(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritdoc} |
80
|
|
|
*/ |
81
|
250 |
|
public function getSchemaManager(Connection $conn) |
82
|
|
|
{ |
83
|
250 |
|
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: