Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
54a6f7b3
Unverified
Commit
54a6f7b3
authored
May 24, 2020
by
Grégoire Paris
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/2.11.x' into 3.0.x
parents
1510b7c1
df651b2d
Changes
34
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
286 additions
and
131 deletions
+286
-131
.appveyor.yml
.appveyor.yml
+2
-25
.coveralls.yml
.coveralls.yml
+2
-0
.gitattributes
.gitattributes
+0
-1
.scrutinizer.yml
.scrutinizer.yml
+0
-34
.travis.yml
.travis.yml
+3
-2
README.md
README.md
+5
-8
UPGRADE.md
UPGRADE.md
+9
-1
doctrine-dbal.php
bin/doctrine-dbal.php
+8
-7
bootstrap.php
ci/continuousphp/bootstrap.php
+0
-15
configuration.rst
docs/en/reference/configuration.rst
+2
-2
phpcs.xml.dist
phpcs.xml.dist
+0
-14
Connection.php
src/Connection.php
+6
-0
Connection.php
src/Driver/Connection.php
+4
-0
DB2Connection.php
src/Driver/IBMDB2/DB2Connection.php
+4
-0
DB2Statement.php
src/Driver/IBMDB2/DB2Statement.php
+4
-0
MysqliConnection.php
src/Driver/Mysqli/MysqliConnection.php
+4
-0
MysqliStatement.php
src/Driver/Mysqli/MysqliStatement.php
+4
-0
OCI8Connection.php
src/Driver/OCI8/OCI8Connection.php
+4
-0
OCI8Statement.php
src/Driver/OCI8/OCI8Statement.php
+4
-0
SQLAnywhereConnection.php
src/Driver/SQLAnywhere/SQLAnywhereConnection.php
+4
-0
SQLAnywhereStatement.php
src/Driver/SQLAnywhere/SQLAnywhereStatement.php
+4
-0
SQLSrvConnection.php
src/Driver/SQLSrv/SQLSrvConnection.php
+4
-0
SQLSrvStatement.php
src/Driver/SQLSrv/SQLSrvStatement.php
+4
-0
Statement.php
src/Driver/Statement.php
+4
-0
RetryableException.php
src/Exception/RetryableException.php
+5
-1
Statement.php
src/Portability/Statement.php
+4
-0
Statement.php
src/Statement.php
+4
-0
ReservedWordsCommand.php
src/Tools/Console/Command/ReservedWordsCommand.php
+48
-8
RunSqlCommand.php
src/Tools/Console/Command/RunSqlCommand.php
+45
-2
ConnectionNotFound.php
src/Tools/Console/ConnectionNotFound.php
+9
-0
ConnectionProvider.php
src/Tools/Console/ConnectionProvider.php
+15
-0
SingleConnectionProvider.php
...s/Console/ConnectionProvider/SingleConnectionProvider.php
+37
-0
ConsoleRunner.php
src/Tools/Console/ConsoleRunner.php
+32
-11
ConnectionHelper.php
src/Tools/Console/Helper/ConnectionHelper.php
+2
-0
No files found.
.appveyor.yml
View file @
54a6f7b3
...
@@ -12,7 +12,6 @@ cache:
...
@@ -12,7 +12,6 @@ cache:
-
C:\tools\php -> .appveyor.yml
-
C:\tools\php -> .appveyor.yml
-
C:\tools\cacert -> .appveyor.yml
-
C:\tools\cacert -> .appveyor.yml
-
C:\tools\composer -> .appveyor.yml
-
C:\tools\composer -> .appveyor.yml
-
C:\tools\ocular -> .appveyor.yml
-
'
%LOCALAPPDATA%\Composer\files
->
composer.json'
-
'
%LOCALAPPDATA%\Composer\files
->
composer.json'
## Build matrix for lowest and highest possible targets
## Build matrix for lowest and highest possible targets
...
@@ -22,20 +21,17 @@ environment:
...
@@ -22,20 +21,17 @@ environment:
driver
:
sqlsrv
driver
:
sqlsrv
db_version
:
sql2012sp1
db_version
:
sql2012sp1
php
:
7.3
php
:
7.3
coverage
:
yes
-
db
:
mssql
-
db
:
mssql
driver
:
sqlsrv
driver
:
sqlsrv
db_version
:
sql2017
db_version
:
sql2017
coverage
:
no
php
:
7.3
php
:
7.3
-
db
:
mssql
-
db
:
mssql
driver
:
pdo_sqlsrv
driver
:
pdo_sqlsrv
db_version
:
sql2017
db_version
:
sql2017
php
:
7.3
php
:
7.3
coverage
:
yes
init
:
init
:
-
SET PATH=C:\Program Files\OpenSSL;c:\tools\php;C:\tools\composer;
C:\tools\ocular;
%PATH%
-
SET PATH=C:\Program Files\OpenSSL;c:\tools\php;C:\tools\composer;%PATH%
-
SET COMPOSER_NO_INTERACTION=1
-
SET COMPOSER_NO_INTERACTION=1
-
SET ANSICON=121x90 (121x90)
-
SET ANSICON=121x90 (121x90)
...
@@ -94,15 +90,6 @@ install:
...
@@ -94,15 +90,6 @@ install:
Set-Content -path 'C:\tools\composer\composer.bat' -Value ('@php C:\tools\composer\composer.phar %*')
Set-Content -path 'C:\tools\composer\composer.bat' -Value ('@php C:\tools\composer\composer.phar %*')
}
}
# download Scrutinizer's Ocular
if (!(Test-Path C:\tools\ocular)) {
New-Item -path c:\tools -name ocular -itemtype directory
}
if (!(Test-Path c:\tools\ocular\ocular.phar)) {
appveyor-retry appveyor DownloadFile https://github.com/scrutinizer-ci/ocular/releases/download/1.5.2/ocular.phar -Filename C:\tools\ocular\ocular.phar
Set-Content -path 'C:\tools\ocular\ocular.bat' -Value ('@php C:\tools\ocular\ocular.phar %*')
}
# download CA bundle
# download CA bundle
if (!(Test-Path C:\tools\cacert)) {
if (!(Test-Path C:\tools\cacert)) {
New-Item -path c:\tools\ -name cacert -itemtype directory
New-Item -path c:\tools\ -name cacert -itemtype directory
...
@@ -132,18 +119,8 @@ test_script:
...
@@ -132,18 +119,8 @@ test_script:
$env:phpunit_config = "ci\appveyor\$($env:db).$($env:driver).appveyor.xml"
$env:phpunit_config = "ci\appveyor\$($env:db).$($env:driver).appveyor.xml"
}
}
if ($env:coverage -eq "yes") {
vendor\bin\phpunit -c $($env:phpunit_config)
vendor\bin\phpunit -c $($env:phpunit_config) --coverage-clover clover.xml
} else {
vendor\bin\phpunit -c $($env:phpunit_config)
}
if ($LastExitCode -ne 0) {
if ($LastExitCode -ne 0) {
$host.SetShouldExit($LastExitCode)
$host.SetShouldExit($LastExitCode)
}
}
after_test
:
-
ps
:
>-
if ($env:coverage -eq "yes") {
appveyor-retry ocular code-coverage:upload --format=php-clover clover.xml
}
.coveralls.yml
0 → 100644
View file @
54a6f7b3
coverage_clover
:
clover.xml
json_path
:
/tmp/coveralls-upload.json
.gitattributes
View file @
54a6f7b3
...
@@ -9,7 +9,6 @@
...
@@ -9,7 +9,6 @@
/phpstan.neon.dist export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/run-all.sh export-ignore
/run-all.sh export-ignore
/.scrutinizer.yml export-ignore
/SECURITY.md export-ignore
/SECURITY.md export-ignore
/tests export-ignore
/tests export-ignore
/.travis.yml export-ignore
/.travis.yml export-ignore
...
...
.scrutinizer.yml
deleted
100644 → 0
View file @
1510b7c1
build
:
nodes
:
analysis
:
environment
:
php
:
version
:
7.3
cache
:
disabled
:
false
directories
:
-
~/.composer/cache
project_setup
:
override
:
true
tests
:
override
:
-
php-scrutinizer-run
before_commands
:
-
"
composer
install
--no-dev
--prefer-source
-a"
tools
:
external_code_coverage
:
timeout
:
3600
runs
:
24
# 21x Travis (jobs with COVERAGE=yes) + 2x AppVeyor (jobs with coverage=yes) + 1x ContinuousPHP
filter
:
excluded_paths
:
-
docs
build_failure_conditions
:
-
'
elements.rating(<=
C).new.exists'
# No new classes/methods with a rating of C or worse allowed
-
'
issues.severity(>=
MAJOR).new.exists'
# New issues of major or higher severity
-
'
project.metric_change("scrutinizer.test_coverage",
<
0)'
# Code Coverage decreased from previous inspection
-
'
patches.label("Unused
Use
Statements").new.exists'
# No new unused imports patches allowed
.travis.yml
View file @
54a6f7b3
...
@@ -11,6 +11,8 @@ before_install:
...
@@ -11,6 +11,8 @@ before_install:
-
|
-
|
if [ "x$COVERAGE" == "xyes" ]; then
if [ "x$COVERAGE" == "xyes" ]; then
pecl install pcov-1.0.6
pecl install pcov-1.0.6
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.2.0/php-coveralls.phar --output-document="${HOME}/bin/coveralls"
chmod +x ${HOME}/bin/coveralls
fi
fi
before_script
:
before_script
:
...
@@ -38,8 +40,7 @@ script:
...
@@ -38,8 +40,7 @@ script:
after_script
:
after_script
:
-
|
-
|
if [ "x$COVERAGE" == "xyes" ]; then
if [ "x$COVERAGE" == "xyes" ]; then
travis_retry wget https://github.com/scrutinizer-ci/ocular/releases/download/1.5.2/ocular.phar
travis_retry coveralls -v
travis_retry php ocular.phar code-coverage:upload --format=php-clover clover.xml
fi
fi
jobs
:
jobs
:
...
...
README.md
View file @
54a6f7b3
...
@@ -4,8 +4,7 @@
...
@@ -4,8 +4,7 @@
|:----------------:|:----------:|
|:----------------:|:----------:|
|
[
![Build status
][
Master image
]
]
[
Master
]
|
[
![Build status
][
2.10 image
]
]
[
2.10
]
|
|
[
![Build status
][
Master image
]
]
[
Master
]
|
[
![Build status
][
2.10 image
]
]
[
2.10
]
|
|
[
![Build Status
][
ContinuousPHP image
]
]
[
ContinuousPHP
]
|
[
![Build Status
][
ContinuousPHP 2.10 image
]
]
[
ContinuousPHP
]
|
|
[
![Build Status
][
ContinuousPHP image
]
]
[
ContinuousPHP
]
|
[
![Build Status
][
ContinuousPHP 2.10 image
]
]
[
ContinuousPHP
]
|
|
[
![Code Coverage
][
Coverage image
]
]
[
Scrutinizer Master
]
|
[
![Code Coverage
][
Coverage 2.10 image
]
]
[
Scrutinizer 2.10
]
|
|
[
![Code Coverage
][
Coverage image
]
]
[
Coveralls Master
]
|
[
![Code Coverage
][
Coverage 2.10 image
]
]
[
Coveralls 2.10
]
|
|
[
![Code Quality
][
Quality image
]
]
[
Scrutinizer Master
]
|
[
![Code Quality
][
Quality 2.10 image
]
]
[
Scrutinizer 2.10
]
|
|
[
![AppVeyor
][
AppVeyor master image
]
]
[
AppVeyor master
]
|
[
![AppVeyor
][
AppVeyor 2.10 image
]
]
[
AppVeyor 2.10
]
|
|
[
![AppVeyor
][
AppVeyor master image
]
]
[
AppVeyor master
]
|
[
![AppVeyor
][
AppVeyor 2.10 image
]
]
[
AppVeyor 2.10
]
|
Powerful database abstraction layer with many features for database schema introspection, schema management and PDO abstraction.
Powerful database abstraction layer with many features for database schema introspection, schema management and PDO abstraction.
...
@@ -17,20 +16,18 @@ Powerful database abstraction layer with many features for database schema intro
...
@@ -17,20 +16,18 @@ Powerful database abstraction layer with many features for database schema intro
*
[
Issue Tracker
](
https://github.com/doctrine/dbal/issues
)
*
[
Issue Tracker
](
https://github.com/doctrine/dbal/issues
)
[
Master image
]:
https://img.shields.io/travis/doctrine/dbal/master.svg?style=flat-square
[
Master image
]:
https://img.shields.io/travis/doctrine/dbal/master.svg?style=flat-square
[
Coverage image
]:
https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/master.svg?style=flat-square
[
Coverage image
]:
https://coveralls.io/repos/github/doctrine/dbal/badge.svg?branch=master
[
Quality image
]:
https://img.shields.io/scrutinizer/g/doctrine/dbal/master.svg?style=flat-square
[
ContinuousPHP image
]:
https://img.shields.io/continuousphp/git-hub/doctrine/dbal/master.svg?style=flat-square
[
ContinuousPHP image
]:
https://img.shields.io/continuousphp/git-hub/doctrine/dbal/master.svg?style=flat-square
[
Master
]:
https://travis-ci.org/doctrine/dbal
[
Master
]:
https://travis-ci.org/doctrine/dbal
[
Scrutinizer Master
]:
https://scrutinizer-ci.com/g/doctrine/dbal/
[
Coveralls Master
]:
https://coveralls.io/github/doctrine/dbal?branch=master
[
AppVeyor master
]:
https://ci.appveyor.com/project/doctrine/dbal/branch/master
[
AppVeyor master
]:
https://ci.appveyor.com/project/doctrine/dbal/branch/master
[
AppVeyor master image
]:
https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/master?svg=true
[
AppVeyor master image
]:
https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/master?svg=true
[
ContinuousPHP
]:
https://continuousphp.com/git-hub/doctrine/dbal
[
ContinuousPHP
]:
https://continuousphp.com/git-hub/doctrine/dbal
[
2.10 image
]:
https://img.shields.io/travis/doctrine/dbal/2.10.x.svg?style=flat-square
[
2.10 image
]:
https://img.shields.io/travis/doctrine/dbal/2.10.x.svg?style=flat-square
[
Coverage 2.10 image
]:
https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/2.10.x.svg?style=flat-square
[
Coverage 2.10 image
]:
https://coveralls.io/repos/github/doctrine/dbal/badge.svg?branch=2.10.x
[
Quality 2.10 image
]:
https://img.shields.io/scrutinizer/g/doctrine/dbal/2.10.x.svg?style=flat-square
[
ContinuousPHP 2.10 image
]:
https://img.shields.io/continuousphp/git-hub/doctrine/dbal/2.10.x.svg?style=flat-square
[
ContinuousPHP 2.10 image
]:
https://img.shields.io/continuousphp/git-hub/doctrine/dbal/2.10.x.svg?style=flat-square
[
2.10
]:
https://github.com/doctrine/dbal/tree/2.10.x
[
2.10
]:
https://github.com/doctrine/dbal/tree/2.10.x
[
Scrutinizer 2.10
]:
https://scrutinizer-ci.com/g/doctrine/dbal/
?branch=2.10.x
[
Coveralls 2.10
]:
https://coveralls.io/github/doctrine/dbal
?branch=2.10.x
[
AppVeyor 2.10
]:
https://ci.appveyor.com/project/doctrine/dbal/branch/2.10.x
[
AppVeyor 2.10
]:
https://ci.appveyor.com/project/doctrine/dbal/branch/2.10.x
[
AppVeyor 2.10 image
]:
https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.10.x?svg=true
[
AppVeyor 2.10 image
]:
https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.10.x?svg=true
UPGRADE.md
View file @
54a6f7b3
...
@@ -138,9 +138,17 @@ Please use other database client applications for import, e.g.:
...
@@ -138,9 +138,17 @@ Please use other database client applications for import, e.g.:
# Upgrade to 2.11
# Upgrade to 2.11
## Deprecated `Connection::project()`
The
`Connection::project()`
method is deprecated. Implement data transformation outside of DBAL.
## Deprecated `Statement::errorCode()` and `errorInfo()`
The
`Statement::errorCode()`
and
`errorInfo()`
methods are deprecated. The error information is available via exceptions.
## Deprecated `EchoSQLLogger`
## Deprecated `EchoSQLLogger`
The
`EchoSQLLogger`
is has been
deprecated. Implement your logger with the desired logic.
The
`EchoSQLLogger`
class is
deprecated. Implement your logger with the desired logic.
## Deprecated database platforms:
## Deprecated database platforms:
...
...
bin/doctrine-dbal.php
View file @
54a6f7b3
<?php
<?php
use
Doctrine\DBAL\Tools\Console\ConnectionProvider
;
use
Doctrine\DBAL\Tools\Console\ConsoleRunner
;
use
Doctrine\DBAL\Tools\Console\ConsoleRunner
;
use
Symfony\Component\Console\Helper\HelperSet
;
use
Symfony\Component\Console\Helper\HelperSet
;
...
@@ -41,17 +42,17 @@ if (! is_readable($configFile)) {
...
@@ -41,17 +42,17 @@ if (! is_readable($configFile)) {
exit
(
1
);
exit
(
1
);
}
}
$commands
=
[];
$commands
=
[];
$helperSet
=
require
$configFile
;
$helperSet
OrConnectionProvider
=
require
$configFile
;
if
(
!
$helperSet
instanceof
HelperSet
)
{
if
(
!
$helperSet
OrConnectionProvider
instanceof
HelperSet
&&
!
$helperSetOrConnectionProvider
instanceof
ConnectionProvider
)
{
foreach
(
$GLOBALS
as
$
helperSetC
andidate
)
{
foreach
(
$GLOBALS
as
$
c
andidate
)
{
if
(
$
helperSetC
andidate
instanceof
HelperSet
)
{
if
(
$
c
andidate
instanceof
HelperSet
)
{
$helperSet
=
$helperSetC
andidate
;
$helperSet
OrConnectionProvider
=
$c
andidate
;
break
;
break
;
}
}
}
}
}
}
ConsoleRunner
::
run
(
$helperSet
,
$commands
);
ConsoleRunner
::
run
(
$helperSet
OrConnectionProvider
,
$commands
);
ci/continuousphp/bootstrap.php
View file @
54a6f7b3
...
@@ -13,19 +13,4 @@ use Doctrine\DBAL\DriverManager;
...
@@ -13,19 +13,4 @@ use Doctrine\DBAL\DriverManager;
'password'
=>
'ORACLE'
,
'password'
=>
'ORACLE'
,
'dbname'
=>
'XE'
,
'dbname'
=>
'XE'
,
])
->
query
(
'ALTER USER ORACLE IDENTIFIED BY ORACLE'
);
])
->
query
(
'ALTER USER ORACLE IDENTIFIED BY ORACLE'
);
$pos
=
array_search
(
'--coverage-clover'
,
$_SERVER
[
'argv'
],
true
);
if
(
$pos
===
false
)
{
return
;
}
$file
=
$_SERVER
[
'argv'
][
$pos
+
1
];
register_shutdown_function
(
static
function
()
use
(
$file
)
:
void
{
$cmd
=
'wget https://github.com/scrutinizer-ci/ocular/releases/download/1.5.2/ocular.phar'
.
' && php ocular.phar code-coverage:upload --format=php-clover '
.
escapeshellarg
(
$file
);
passthru
(
$cmd
);
});
})();
})();
docs/en/reference/configuration.rst
View file @
54a6f7b3
...
@@ -64,12 +64,12 @@ For example, to connect to a "foo" MySQL DB using the ``pdo_mysql``
...
@@ -64,12 +64,12 @@ For example, to connect to a "foo" MySQL DB using the ``pdo_mysql``
driver on localhost port 4486 with the charset set to UTF-8, you
driver on localhost port 4486 with the charset set to UTF-8, you
would use the following URL::
would use the following URL::
mysql://localhost:4486/foo?charset=UTF
-
8
mysql://localhost:4486/foo?charset=UTF8
This is identical to the following connection string using the
This is identical to the following connection string using the
full driver name::
full driver name::
pdo-mysql://localhost:4486/foo?charset=UTF
-
8
pdo-mysql://localhost:4486/foo?charset=UTF8
In the example above, mind the dashes instead of the
In the example above, mind the dashes instead of the
underscores in the URL scheme.
underscores in the URL scheme.
...
...
phpcs.xml.dist
View file @
54a6f7b3
...
@@ -37,10 +37,6 @@
...
@@ -37,10 +37,6 @@
</properties>
</properties>
</rule>
</rule>
<rule
ref=
"Squiz.NamingConventions.ValidVariableName.PublicHasUnderscore"
>
<exclude-pattern>
*/src/*
</exclude-pattern>
</rule>
<rule
ref=
"SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"
>
<rule
ref=
"SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"
>
<exclude-pattern>
*/src/*
</exclude-pattern>
<exclude-pattern>
*/src/*
</exclude-pattern>
</rule>
</rule>
...
@@ -65,11 +61,6 @@
...
@@ -65,11 +61,6 @@
<exclude-pattern>
tests/Tools/TestAsset/*
</exclude-pattern>
<exclude-pattern>
tests/Tools/TestAsset/*
</exclude-pattern>
</rule>
</rule>
<!-- https://github.com/slevomat/coding-standard/issues/868 -->
<rule
ref=
"SlevomatCodingStandard.PHP.UselessParentheses.UselessParentheses"
>
<exclude-pattern>
ci/continuousphp/bootstrap.php
</exclude-pattern>
</rule>
<!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/2099 -->
<!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/2099 -->
<rule
ref=
"Squiz.Commenting.FunctionComment.InvalidNoReturn"
>
<rule
ref=
"Squiz.Commenting.FunctionComment.InvalidNoReturn"
>
<exclude-pattern>
src/Platforms/AbstractPlatform.php
</exclude-pattern>
<exclude-pattern>
src/Platforms/AbstractPlatform.php
</exclude-pattern>
...
@@ -107,11 +98,6 @@
...
@@ -107,11 +98,6 @@
<exclude-pattern>
src/Driver/SQLSrv/SQLSrvStatement.php
</exclude-pattern>
<exclude-pattern>
src/Driver/SQLSrv/SQLSrvStatement.php
</exclude-pattern>
</rule>
</rule>
<!-- sqlsrv functions are documented in upper case but reflected in lower case -->
<rule
ref=
"Squiz.PHP.LowercasePHPFunctions.CallUppercase"
>
<exclude-pattern>
src/Driver/SQLSrv/SQLSrvStatement.php
</exclude-pattern>
</rule>
<!-- see https://github.com/doctrine/dbal/issues/3377 -->
<!-- see https://github.com/doctrine/dbal/issues/3377 -->
<rule
ref=
"SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedNotEqualOperator"
>
<rule
ref=
"SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedNotEqualOperator"
>
<exclude-pattern>
src/Schema/Comparator.php
</exclude-pattern>
<exclude-pattern>
src/Schema/Comparator.php
</exclude-pattern>
...
...
src/Connection.php
View file @
54a6f7b3
...
@@ -962,6 +962,8 @@ class Connection implements DriverConnection
...
@@ -962,6 +962,8 @@ class Connection implements DriverConnection
* Executes an, optionally parametrized, SQL query and returns the result,
* Executes an, optionally parametrized, SQL query and returns the result,
* applying a given projection/transformation function on each row of the result.
* applying a given projection/transformation function on each row of the result.
*
*
* @deprecated
*
* @param string $query The SQL query to execute.
* @param string $query The SQL query to execute.
* @param mixed[] $params The parameters, if any.
* @param mixed[] $params The parameters, if any.
* @param Closure $function The transformation function that is applied on each row.
* @param Closure $function The transformation function that is applied on each row.
...
@@ -1092,6 +1094,8 @@ class Connection implements DriverConnection
...
@@ -1092,6 +1094,8 @@ class Connection implements DriverConnection
/**
/**
* Fetches the SQLSTATE associated with the last database operation.
* Fetches the SQLSTATE associated with the last database operation.
*
*
* @deprecated The error information is available via exceptions.
*
* @return string|null The last error code.
* @return string|null The last error code.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
...
@@ -1101,6 +1105,8 @@ class Connection implements DriverConnection
...
@@ -1101,6 +1105,8 @@ class Connection implements DriverConnection
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Driver/Connection.php
View file @
54a6f7b3
...
@@ -75,6 +75,8 @@ interface Connection
...
@@ -75,6 +75,8 @@ interface Connection
/**
/**
* Returns the error code associated with the last operation on the database handle.
* Returns the error code associated with the last operation on the database handle.
*
*
* @deprecated The error information is available via exceptions.
*
* @return string|null The error code, or null if no operation has been run on the database handle.
* @return string|null The error code, or null if no operation has been run on the database handle.
*/
*/
public
function
errorCode
();
public
function
errorCode
();
...
@@ -82,6 +84,8 @@ interface Connection
...
@@ -82,6 +84,8 @@ interface Connection
/**
/**
* Returns extended error information associated with the last operation on the database handle.
* Returns extended error information associated with the last operation on the database handle.
*
*
* @deprecated The error information is available via exceptions.
*
* @return mixed[]
* @return mixed[]
*/
*/
public
function
errorInfo
();
public
function
errorInfo
();
...
...
src/Driver/IBMDB2/DB2Connection.php
View file @
54a6f7b3
...
@@ -169,6 +169,8 @@ class DB2Connection implements ServerInfoAwareConnection
...
@@ -169,6 +169,8 @@ class DB2Connection implements ServerInfoAwareConnection
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
{
{
...
@@ -177,6 +179,8 @@ class DB2Connection implements ServerInfoAwareConnection
...
@@ -177,6 +179,8 @@ class DB2Connection implements ServerInfoAwareConnection
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Driver/IBMDB2/DB2Statement.php
View file @
54a6f7b3
...
@@ -156,6 +156,8 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -156,6 +156,8 @@ class DB2Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
{
{
...
@@ -164,6 +166,8 @@ class DB2Statement implements IteratorAggregate, Statement
...
@@ -164,6 +166,8 @@ class DB2Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Driver/Mysqli/MysqliConnection.php
View file @
54a6f7b3
...
@@ -195,6 +195,8 @@ class MysqliConnection implements PingableConnection, ServerInfoAwareConnection
...
@@ -195,6 +195,8 @@ class MysqliConnection implements PingableConnection, ServerInfoAwareConnection
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
{
{
...
@@ -203,6 +205,8 @@ class MysqliConnection implements PingableConnection, ServerInfoAwareConnection
...
@@ -203,6 +205,8 @@ class MysqliConnection implements PingableConnection, ServerInfoAwareConnection
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Driver/Mysqli/MysqliStatement.php
View file @
54a6f7b3
...
@@ -389,6 +389,8 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -389,6 +389,8 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
{
{
...
@@ -397,6 +399,8 @@ class MysqliStatement implements IteratorAggregate, Statement
...
@@ -397,6 +399,8 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Driver/OCI8/OCI8Connection.php
View file @
54a6f7b3
...
@@ -205,6 +205,8 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
...
@@ -205,6 +205,8 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
{
{
...
@@ -218,6 +220,8 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
...
@@ -218,6 +220,8 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Driver/OCI8/OCI8Statement.php
View file @
54a6f7b3
...
@@ -356,6 +356,8 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -356,6 +356,8 @@ class OCI8Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
{
{
...
@@ -369,6 +371,8 @@ class OCI8Statement implements IteratorAggregate, Statement
...
@@ -369,6 +371,8 @@ class OCI8Statement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Driver/SQLAnywhere/SQLAnywhereConnection.php
View file @
54a6f7b3
...
@@ -90,6 +90,8 @@ class SQLAnywhereConnection implements ServerInfoAwareConnection
...
@@ -90,6 +90,8 @@ class SQLAnywhereConnection implements ServerInfoAwareConnection
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
{
{
...
@@ -98,6 +100,8 @@ class SQLAnywhereConnection implements ServerInfoAwareConnection
...
@@ -98,6 +100,8 @@ class SQLAnywhereConnection implements ServerInfoAwareConnection
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Driver/SQLAnywhere/SQLAnywhereStatement.php
View file @
54a6f7b3
...
@@ -137,6 +137,8 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -137,6 +137,8 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
{
{
...
@@ -145,6 +147,8 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
...
@@ -145,6 +147,8 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Driver/SQLSrv/SQLSrvConnection.php
View file @
54a6f7b3
...
@@ -171,6 +171,8 @@ class SQLSrvConnection implements ServerInfoAwareConnection
...
@@ -171,6 +171,8 @@ class SQLSrvConnection implements ServerInfoAwareConnection
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
{
{
...
@@ -184,6 +186,8 @@ class SQLSrvConnection implements ServerInfoAwareConnection
...
@@ -184,6 +186,8 @@ class SQLSrvConnection implements ServerInfoAwareConnection
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Driver/SQLSrv/SQLSrvStatement.php
View file @
54a6f7b3
...
@@ -203,6 +203,8 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -203,6 +203,8 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
{
{
...
@@ -216,6 +218,8 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -216,6 +218,8 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Driver/Statement.php
View file @
54a6f7b3
...
@@ -60,6 +60,8 @@ interface Statement extends ResultStatement
...
@@ -60,6 +60,8 @@ interface Statement extends ResultStatement
/**
/**
* Fetches the SQLSTATE associated with the last operation on the statement handle.
* Fetches the SQLSTATE associated with the last operation on the statement handle.
*
*
* @deprecated The error information is available via exceptions.
*
* @see Doctrine_Adapter_Interface::errorCode()
* @see Doctrine_Adapter_Interface::errorCode()
*
*
* @return string|int|bool The error code string.
* @return string|int|bool The error code string.
...
@@ -69,6 +71,8 @@ interface Statement extends ResultStatement
...
@@ -69,6 +71,8 @@ interface Statement extends ResultStatement
/**
/**
* Fetches extended error information associated with the last operation on the statement handle.
* Fetches extended error information associated with the last operation on the statement handle.
*
*
* @deprecated The error information is available via exceptions.
*
* @return mixed[] The error info array.
* @return mixed[] The error info array.
*/
*/
public
function
errorInfo
();
public
function
errorInfo
();
...
...
src/Exception/RetryableException.php
View file @
54a6f7b3
...
@@ -2,9 +2,13 @@
...
@@ -2,9 +2,13 @@
namespace
Doctrine\DBAL\Exception
;
namespace
Doctrine\DBAL\Exception
;
use
Throwable
;
/**
/**
* Marker interface for all exceptions where retrying the transaction makes sense.
* Marker interface for all exceptions where retrying the transaction makes sense.
*
* @psalm-immutable
*/
*/
interface
RetryableException
interface
RetryableException
extends
Throwable
{
{
}
}
src/Portability/Statement.php
View file @
54a6f7b3
...
@@ -80,6 +80,8 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -80,6 +80,8 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorCode
()
public
function
errorCode
()
{
{
...
@@ -90,6 +92,8 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -90,6 +92,8 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Statement.php
View file @
54a6f7b3
...
@@ -196,6 +196,8 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -196,6 +196,8 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* Fetches the SQLSTATE associated with the last operation on the statement.
* Fetches the SQLSTATE associated with the last operation on the statement.
*
*
* @deprecated The error information is available via exceptions.
*
* @return string|int|bool
* @return string|int|bool
*/
*/
public
function
errorCode
()
public
function
errorCode
()
...
@@ -205,6 +207,8 @@ class Statement implements IteratorAggregate, DriverStatement
...
@@ -205,6 +207,8 @@ class Statement implements IteratorAggregate, DriverStatement
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*
* @deprecated The error information is available via exceptions.
*/
*/
public
function
errorInfo
()
public
function
errorInfo
()
{
{
...
...
src/Tools/Console/Command/ReservedWordsCommand.php
View file @
54a6f7b3
...
@@ -15,6 +15,8 @@ use Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator;
...
@@ -15,6 +15,8 @@ use Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator;
use
Doctrine\DBAL\Platforms\Keywords\SQLAnywhereKeywords
;
use
Doctrine\DBAL\Platforms\Keywords\SQLAnywhereKeywords
;
use
Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords
;
use
Doctrine\DBAL\Platforms\Keywords\SQLiteKeywords
;
use
Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords
;
use
Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords
;
use
Doctrine\DBAL\Tools\Console\ConnectionProvider
;
use
Exception
;
use
InvalidArgumentException
;
use
InvalidArgumentException
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Input\InputInterface
;
...
@@ -24,6 +26,9 @@ use function array_keys;
...
@@ -24,6 +26,9 @@ use function array_keys;
use
function
assert
;
use
function
assert
;
use
function
count
;
use
function
count
;
use
function
implode
;
use
function
implode
;
use
function
is_string
;
use
function
trigger_error
;
use
const
E_USER_DEPRECATED
;
class
ReservedWordsCommand
extends
Command
class
ReservedWordsCommand
extends
Command
{
{
...
@@ -42,6 +47,20 @@ class ReservedWordsCommand extends Command
...
@@ -42,6 +47,20 @@ class ReservedWordsCommand extends Command
'sqlserver'
=>
SQLServer2012Keywords
::
class
,
'sqlserver'
=>
SQLServer2012Keywords
::
class
,
];
];
/** @var ConnectionProvider|null */
private
$connectionProvider
;
public
function
__construct
(
?
ConnectionProvider
$connectionProvider
=
null
)
{
parent
::
__construct
();
$this
->
connectionProvider
=
$connectionProvider
;
if
(
$connectionProvider
!==
null
)
{
return
;
}
@
trigger_error
(
'Not passing a connection provider as the first constructor argument is deprecated'
,
E_USER_DEPRECATED
);
}
/**
/**
* If you want to add or replace a keywords list use this command.
* If you want to add or replace a keywords list use this command.
*
*
...
@@ -61,12 +80,14 @@ class ReservedWordsCommand extends Command
...
@@ -61,12 +80,14 @@ class ReservedWordsCommand extends Command
$this
$this
->
setName
(
'dbal:reserved-words'
)
->
setName
(
'dbal:reserved-words'
)
->
setDescription
(
'Checks if the current database contains identifiers that are reserved.'
)
->
setDescription
(
'Checks if the current database contains identifiers that are reserved.'
)
->
setDefinition
([
new
InputOption
(
->
setDefinition
([
'list'
,
new
InputOption
(
'connection'
,
null
,
InputOption
::
VALUE_REQUIRED
,
'The named database connection'
),
'l'
,
new
InputOption
(
InputOption
::
VALUE_OPTIONAL
|
InputOption
::
VALUE_IS_ARRAY
,
'list'
,
'Keyword-List name.'
'l'
,
),
InputOption
::
VALUE_OPTIONAL
|
InputOption
::
VALUE_IS_ARRAY
,
'Keyword-List name.'
),
])
])
->
setHelp
(
<<<EOT
->
setHelp
(
<<<EOT
Checks if the current database contains tables and columns
Checks if the current database contains tables and columns
...
@@ -105,8 +126,7 @@ EOT
...
@@ -105,8 +126,7 @@ EOT
*/
*/
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
{
$conn
=
$this
->
getHelper
(
'db'
)
->
getConnection
();
$conn
=
$this
->
getConnection
(
$input
);
assert
(
$conn
instanceof
Connection
);
$keywordLists
=
(
array
)
$input
->
getOption
(
'list'
);
$keywordLists
=
(
array
)
$input
->
getOption
(
'list'
);
if
(
count
(
$keywordLists
)
===
0
)
{
if
(
count
(
$keywordLists
)
===
0
)
{
...
@@ -146,4 +166,24 @@ EOT
...
@@ -146,4 +166,24 @@ EOT
return
0
;
return
0
;
}
}
private
function
getConnection
(
InputInterface
$input
)
:
Connection
{
$connectionName
=
$input
->
getOption
(
'connection'
);
assert
(
is_string
(
$connectionName
)
||
$connectionName
===
null
);
if
(
$this
->
connectionProvider
===
null
)
{
if
(
$connectionName
!==
null
)
{
throw
new
Exception
(
'Specifying a connection is only supported when a ConnectionProvider is used.'
);
}
return
$this
->
getHelper
(
'db'
)
->
getConnection
();
}
if
(
$connectionName
!==
null
)
{
return
$this
->
connectionProvider
->
getConnection
(
$connectionName
);
}
return
$this
->
connectionProvider
->
getDefaultConnection
();
}
}
}
src/Tools/Console/Command/RunSqlCommand.php
View file @
54a6f7b3
...
@@ -2,7 +2,10 @@
...
@@ -2,7 +2,10 @@
namespace
Doctrine\DBAL\Tools\Console\Command
;
namespace
Doctrine\DBAL\Tools\Console\Command
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Tools\Console\ConnectionProvider
;
use
Doctrine\DBAL\Tools\Dumper
;
use
Doctrine\DBAL\Tools\Dumper
;
use
Exception
;
use
LogicException
;
use
LogicException
;
use
RuntimeException
;
use
RuntimeException
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Command\Command
;
...
@@ -15,6 +18,8 @@ use function is_bool;
...
@@ -15,6 +18,8 @@ use function is_bool;
use
function
is_numeric
;
use
function
is_numeric
;
use
function
is_string
;
use
function
is_string
;
use
function
stripos
;
use
function
stripos
;
use
function
trigger_error
;
use
const
E_USER_DEPRECATED
;
/**
/**
* Task for executing arbitrary SQL that can come from a file or directly from
* Task for executing arbitrary SQL that can come from a file or directly from
...
@@ -22,6 +27,20 @@ use function stripos;
...
@@ -22,6 +27,20 @@ use function stripos;
*/
*/
class
RunSqlCommand
extends
Command
class
RunSqlCommand
extends
Command
{
{
/** @var ConnectionProvider|null */
private
$connectionProvider
;
public
function
__construct
(
?
ConnectionProvider
$connectionProvider
=
null
)
{
parent
::
__construct
();
$this
->
connectionProvider
=
$connectionProvider
;
if
(
$connectionProvider
!==
null
)
{
return
;
}
@
trigger_error
(
'Not passing a connection provider as the first constructor argument is deprecated'
,
E_USER_DEPRECATED
);
}
/** @return void */
/** @return void */
protected
function
configure
()
protected
function
configure
()
{
{
...
@@ -29,12 +48,16 @@ class RunSqlCommand extends Command
...
@@ -29,12 +48,16 @@ class RunSqlCommand extends Command
->
setName
(
'dbal:run-sql'
)
->
setName
(
'dbal:run-sql'
)
->
setDescription
(
'Executes arbitrary SQL directly from the command line.'
)
->
setDescription
(
'Executes arbitrary SQL directly from the command line.'
)
->
setDefinition
([
->
setDefinition
([
new
InputOption
(
'connection'
,
null
,
InputOption
::
VALUE_REQUIRED
,
'The named database connection'
),
new
InputArgument
(
'sql'
,
InputArgument
::
REQUIRED
,
'The SQL statement to execute.'
),
new
InputArgument
(
'sql'
,
InputArgument
::
REQUIRED
,
'The SQL statement to execute.'
),
new
InputOption
(
'depth'
,
null
,
InputOption
::
VALUE_REQUIRED
,
'Dumping depth of result set.'
,
7
),
new
InputOption
(
'depth'
,
null
,
InputOption
::
VALUE_REQUIRED
,
'Dumping depth of result set.'
,
7
),
new
InputOption
(
'force-fetch'
,
null
,
InputOption
::
VALUE_NONE
,
'Forces fetching the result.'
),
new
InputOption
(
'force-fetch'
,
null
,
InputOption
::
VALUE_NONE
,
'Forces fetching the result.'
),
])
])
->
setHelp
(
<<<EOT
->
setHelp
(
<<<EOT
Executes arbitrary SQL directly from the command line.
The <info>%command.name%</info> command executes the given SQL query and
outputs the results:
<info>php %command.full_name% "SELECT * FROM users"</info>
EOT
EOT
);
);
}
}
...
@@ -44,7 +67,7 @@ EOT
...
@@ -44,7 +67,7 @@ EOT
*/
*/
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
{
$conn
=
$this
->
get
Helper
(
'db'
)
->
getConnection
(
);
$conn
=
$this
->
get
Connection
(
$input
);
$sql
=
$input
->
getArgument
(
'sql'
);
$sql
=
$input
->
getArgument
(
'sql'
);
...
@@ -73,4 +96,24 @@ EOT
...
@@ -73,4 +96,24 @@ EOT
return
0
;
return
0
;
}
}
private
function
getConnection
(
InputInterface
$input
)
:
Connection
{
$connectionName
=
$input
->
getOption
(
'connection'
);
assert
(
is_string
(
$connectionName
)
||
$connectionName
===
null
);
if
(
$this
->
connectionProvider
===
null
)
{
if
(
$connectionName
!==
null
)
{
throw
new
Exception
(
'Specifying a connection is only supported when a ConnectionProvider is used.'
);
}
return
$this
->
getHelper
(
'db'
)
->
getConnection
();
}
if
(
$connectionName
!==
null
)
{
return
$this
->
connectionProvider
->
getConnection
(
$connectionName
);
}
return
$this
->
connectionProvider
->
getDefaultConnection
();
}
}
}
src/Tools/Console/ConnectionNotFound.php
0 → 100644
View file @
54a6f7b3
<?php
namespace
Doctrine\DBAL\Tools\Console
;
use
OutOfBoundsException
;
final
class
ConnectionNotFound
extends
OutOfBoundsException
{
}
src/Tools/Console/ConnectionProvider.php
0 → 100644
View file @
54a6f7b3
<?php
namespace
Doctrine\DBAL\Tools\Console
;
use
Doctrine\DBAL\Connection
;
interface
ConnectionProvider
{
public
function
getDefaultConnection
()
:
Connection
;
/**
* @throws ConnectionNotFound in case a connection with the given name does not exist.
*/
public
function
getConnection
(
string
$name
)
:
Connection
;
}
src/Tools/Console/ConnectionProvider/SingleConnectionProvider.php
0 → 100644
View file @
54a6f7b3
<?php
namespace
Doctrine\DBAL\Tools\Console\ConnectionProvider
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Tools\Console\ConnectionNotFound
;
use
Doctrine\DBAL\Tools\Console\ConnectionProvider
;
use
function
sprintf
;
class
SingleConnectionProvider
implements
ConnectionProvider
{
/** @var Connection */
private
$connection
;
/** @var string */
private
$defaultConnectionName
;
public
function
__construct
(
Connection
$connection
,
string
$defaultConnectionName
=
'default'
)
{
$this
->
connection
=
$connection
;
$this
->
defaultConnectionName
=
$defaultConnectionName
;
}
public
function
getDefaultConnection
()
:
Connection
{
return
$this
->
connection
;
}
public
function
getConnection
(
string
$name
)
:
Connection
{
if
(
$name
!==
$this
->
defaultConnectionName
)
{
throw
new
ConnectionNotFound
(
sprintf
(
'Connection with name "%s" does not exist.'
,
$name
));
}
return
$this
->
connection
;
}
}
src/Tools/Console/ConsoleRunner.php
View file @
54a6f7b3
...
@@ -10,6 +10,10 @@ use PackageVersions\Versions;
...
@@ -10,6 +10,10 @@ use PackageVersions\Versions;
use
Symfony\Component\Console\Application
;
use
Symfony\Component\Console\Application
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Helper\HelperSet
;
use
Symfony\Component\Console\Helper\HelperSet
;
use
TypeError
;
use
function
sprintf
;
use
function
trigger_error
;
use
const
E_USER_DEPRECATED
;
/**
/**
* Handles running the Console Tools inside Symfony Console context.
* Handles running the Console Tools inside Symfony Console context.
...
@@ -19,6 +23,8 @@ class ConsoleRunner
...
@@ -19,6 +23,8 @@ class ConsoleRunner
/**
/**
* Create a Symfony Console HelperSet
* Create a Symfony Console HelperSet
*
*
* @deprecated use a ConnectionProvider instead.
*
* @return HelperSet
* @return HelperSet
*/
*/
public
static
function
createHelperSet
(
Connection
$connection
)
public
static
function
createHelperSet
(
Connection
$connection
)
...
@@ -29,20 +35,31 @@ class ConsoleRunner
...
@@ -29,20 +35,31 @@ class ConsoleRunner
}
}
/**
/**
* Runs console with the given
helperset
.
* Runs console with the given
connection provider or helperset (deprecated)
.
*
*
* @param Command[] $commands
* @param ConnectionProvider|HelperSet $helperSetOrConnectionProvider
* @param Command[] $commands
*
*
* @return void
* @return void
*/
*/
public
static
function
run
(
HelperSet
$helperSet
,
$commands
=
[])
public
static
function
run
(
$helperSetOrConnectionProvider
,
$commands
=
[])
{
{
$cli
=
new
Application
(
'Doctrine Command Line Interface'
,
Versions
::
getVersion
(
'doctrine/dbal'
));
$cli
=
new
Application
(
'Doctrine Command Line Interface'
,
Versions
::
getVersion
(
'doctrine/dbal'
));
$cli
->
setCatchExceptions
(
true
);
$cli
->
setCatchExceptions
(
true
);
$cli
->
setHelperSet
(
$helperSet
);
self
::
addCommands
(
$cli
);
$connectionProvider
=
null
;
if
(
$helperSetOrConnectionProvider
instanceof
HelperSet
)
{
@
trigger_error
(
sprintf
(
'Passing an instance of "%s" as the first argument is deprecated. Pass an instance of "%s" instead.'
,
HelperSet
::
class
,
ConnectionProvider
::
class
),
E_USER_DEPRECATED
);
$connectionProvider
=
null
;
$cli
->
setHelperSet
(
$helperSetOrConnectionProvider
);
}
elseif
(
$helperSetOrConnectionProvider
instanceof
ConnectionProvider
)
{
$connectionProvider
=
$helperSetOrConnectionProvider
;
}
else
{
throw
new
TypeError
(
sprintf
(
'First argument must be an instance of "%s" or "%s"'
,
HelperSet
::
class
,
ConnectionProvider
::
class
));
}
self
::
addCommands
(
$cli
,
$connectionProvider
);
$cli
->
addCommands
(
$commands
);
$cli
->
addCommands
(
$commands
);
$cli
->
run
();
$cli
->
run
();
...
@@ -51,11 +68,12 @@ class ConsoleRunner
...
@@ -51,11 +68,12 @@ class ConsoleRunner
/**
/**
* @return void
* @return void
*/
*/
public
static
function
addCommands
(
Application
$cli
)
public
static
function
addCommands
(
Application
$cli
,
?
ConnectionProvider
$connectionProvider
=
null
)
{
{
$cli
->
addCommands
([
$cli
->
addCommands
([
new
RunSqlCommand
(),
new
RunSqlCommand
(),
new
ReservedWordsCommand
(),
new
ReservedWordsCommand
(),
new
ReservedWordsCommand
(
$connectionProvider
),
]);
]);
}
}
...
@@ -72,14 +90,17 @@ project, which is required to get the Doctrine-DBAL Console working. You can use
...
@@ -72,14 +90,17 @@ project, which is required to get the Doctrine-DBAL Console working. You can use
following sample as a template:
following sample as a template:
<?php
<?php
use Doctrine\DBAL\Tools\Console\ConsoleRunner;
use Doctrine\DBAL\Tools\Console\ConnectionProvider\SingleConnectionProvider;
// replace with the mechanism to retrieve DBAL connection in your app
$connection = getDBALConnection();
// You can append new commands to $commands array, if needed
// You can append new commands to $commands array, if needed
return ConsoleRunner::createHelperSet($connection);
// replace with the mechanism to retrieve DBAL connection(s) in your app
// and return a Doctrine\DBAL\Tools\Console\ConnectionProvider instance.
$connection = getDBALConnection();
// in case you have a single connection you can use SingleConnectionProvider
// otherwise you need to implement the Doctrine\DBAL\Tools\Console\ConnectionProvider interface with your custom logic
return new SingleConnectionProvider($connection);
HELP;
HELP;
}
}
...
...
src/Tools/Console/Helper/ConnectionHelper.php
View file @
54a6f7b3
...
@@ -7,6 +7,8 @@ use Symfony\Component\Console\Helper\Helper;
...
@@ -7,6 +7,8 @@ use Symfony\Component\Console\Helper\Helper;
/**
/**
* Doctrine CLI Connection Helper.
* Doctrine CLI Connection Helper.
*
* @deprecated use a ConnectionProvider instead.
*/
*/
class
ConnectionHelper
extends
Helper
class
ConnectionHelper
extends
Helper
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment