composer update
This commit is contained in:
49
vendor/doctrine/dbal/.doctrine-project.json
vendored
Normal file
49
vendor/doctrine/dbal/.doctrine-project.json
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"active": true,
|
||||
"name": "Database Abstraction Layer",
|
||||
"shortName": "DBAL",
|
||||
"slug": "dbal",
|
||||
"docsSlug": "doctrine-dbal",
|
||||
"versions": [
|
||||
{
|
||||
"name": "3.0",
|
||||
"branchName": "develop",
|
||||
"slug": "latest",
|
||||
"upcoming": true
|
||||
},
|
||||
{
|
||||
"name": "2.9",
|
||||
"branchName": "master",
|
||||
"slug": "2.9",
|
||||
"upcoming": true
|
||||
},
|
||||
{
|
||||
"name": "2.8",
|
||||
"branchName": "2.8",
|
||||
"slug": "2.8",
|
||||
"current": true,
|
||||
"aliases": [
|
||||
"current",
|
||||
"stable"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "2.7",
|
||||
"branchName": "2.7",
|
||||
"slug": "2.7",
|
||||
"maintained": false
|
||||
},
|
||||
{
|
||||
"name": "2.6",
|
||||
"branchName": "2.6",
|
||||
"slug": "2.6",
|
||||
"maintained": false
|
||||
},
|
||||
{
|
||||
"name": "2.5",
|
||||
"branchName": "2.5",
|
||||
"slug": "2.5",
|
||||
"maintained": false
|
||||
}
|
||||
]
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
---
|
||||
name: 💥 BC Break
|
||||
about: Have you encountered an issue during upgrade? 💣
|
||||
---
|
||||
|
||||
<!--
|
||||
Before reporting a BC break, please consult the upgrading document to make sure it's not an expected change: https://github.com/doctrine/dbal/blob/master/UPGRADE.md
|
||||
-->
|
||||
|
||||
### BC Break Report
|
||||
|
||||
<!-- Fill in the relevant information below to help triage your issue. -->
|
||||
|
||||
| Q | A
|
||||
|------------ | ------
|
||||
| BC Break | yes
|
||||
| Version | x.y.z
|
||||
|
||||
#### Summary
|
||||
|
||||
<!-- Provide a summary desciribing the problem you are experiencing. -->
|
||||
|
||||
#### Previous behavior
|
||||
|
||||
<!-- What was the previous (working) behavior? -->
|
||||
|
||||
#### Current behavior
|
||||
|
||||
<!-- What is the current (broken) behavior? -->
|
||||
|
||||
#### How to reproduce
|
||||
|
||||
<!--
|
||||
Provide steps to reproduce the BC break.
|
||||
If possible, also add a code snippet with relevant configuration, driver/platform information, SQL queries, etc.
|
||||
Adding a failing Unit or Functional Test would help us a lot - you can submit it in a Pull Request separately, referencing this bug report.
|
||||
-->
|
@@ -1,34 +0,0 @@
|
||||
---
|
||||
name: 🐞 Bug Report
|
||||
about: Something is broken? 🔨
|
||||
---
|
||||
|
||||
### Bug Report
|
||||
|
||||
<!-- Fill in the relevant information below to help triage your issue. -->
|
||||
|
||||
| Q | A
|
||||
|------------ | ------
|
||||
| BC Break | yes/no
|
||||
| Version | x.y.z
|
||||
|
||||
#### Summary
|
||||
|
||||
<!-- Provide a summary desciribing the problem you are experiencing. -->
|
||||
|
||||
#### Current behavior
|
||||
|
||||
<!-- What is the current (buggy) behavior? -->
|
||||
|
||||
#### How to reproduce
|
||||
|
||||
<!--
|
||||
Provide steps to reproduce the bug.
|
||||
If possible, also add a code snippet with relevant configuration, driver/platform information, SQL queries, etc.
|
||||
Adding a failing Unit or Functional Test would help us a lot - you can submit one in a Pull Request separately, referencing this bug report.
|
||||
-->
|
||||
|
||||
#### Expected behavior
|
||||
|
||||
<!-- What was the expected (correct) behavior? -->
|
||||
|
@@ -1,18 +0,0 @@
|
||||
---
|
||||
name: 🎉 Feature Request
|
||||
about: You have a neat idea that should be implemented? 🎩
|
||||
---
|
||||
|
||||
### Feature Request
|
||||
|
||||
<!-- Fill in the relevant information below to help triage your issue. -->
|
||||
|
||||
| Q | A
|
||||
|------------ | ------
|
||||
| New Feature | yes
|
||||
| RFC | yes/no
|
||||
| BC Break | yes/no
|
||||
|
||||
#### Summary
|
||||
|
||||
<!-- Provide a summary of the feature you would like to see implemented. -->
|
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: ❓ Support Question
|
||||
about: Have a problem that you can't figure out? 🤔
|
||||
---
|
||||
|
||||
<!-- Fill in the relevant information below to help triage your issue. -->
|
||||
|
||||
| Q | A
|
||||
|------------ | -----
|
||||
| Version | x.y.z
|
||||
|
||||
<!--
|
||||
Before asking question here, please try asking on Gitter or Slack first.
|
||||
Find out more about Doctrine support channels here: https://www.doctrine-project.org/community/
|
||||
Keep in mind that GitHub is primarily an issue tracker.
|
||||
-->
|
||||
|
||||
### Support Question
|
||||
|
||||
<!-- Describe the issue you are facing here. -->
|
@@ -1,11 +0,0 @@
|
||||
<!-- Fill in the relevant information below to help triage your pull request. -->
|
||||
|
||||
| Q | A
|
||||
|------------- | -----------
|
||||
| Type | bug/feature/improvement
|
||||
| BC Break | yes/no
|
||||
| Fixed issues | <!-- use #NUM format to reference an issue -->
|
||||
|
||||
#### Summary
|
||||
|
||||
<!-- Provide a summary your change. -->
|
34
vendor/doctrine/dbal/.scrutinizer.yml
vendored
34
vendor/doctrine/dbal/.scrutinizer.yml
vendored
@@ -1,34 +0,0 @@
|
||||
build:
|
||||
nodes:
|
||||
analysis:
|
||||
environment:
|
||||
php:
|
||||
version: 7.1
|
||||
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: 22 # 18x Travis (jobs with COVERAGE=yes) + 3x 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
|
36
vendor/doctrine/dbal/README.md
vendored
36
vendor/doctrine/dbal/README.md
vendored
@@ -1,12 +1,12 @@
|
||||
# Doctrine DBAL
|
||||
|
||||
| [Master][Master] | [2.7][2.7] | [2.6][2.6] | [Develop][develop] |
|
||||
|:----------------:|:----------:|:----------:|:--------------:|
|
||||
| [![Build status][Master image]][Master] | [![Build status][2.7 image]][2.7] | [![Build status][2.6 image]][2.6] | [![Build status][develop image]][develop] |
|
||||
| [![Build Status][ContinuousPHP image]][ContinuousPHP] | [![Build Status][ContinuousPHP 2.7 image]][ContinuousPHP] | [![Build Status][ContinuousPHP 2.6 image]][ContinuousPHP] | [![Build Status][ContinuousPHP develop image]][ContinuousPHP] |
|
||||
| [![Code Coverage][Coverage image]][Scrutinizer Master] | [![Code Coverage][Coverage 2.7 image]][Scrutinizer 2.7] | [![Code Coverage][Coverage 2.6 image]][Scrutinizer 2.6] | [![Code Coverage][Coverage develop image]][Scrutinizer develop] |
|
||||
| [![Code Quality][Quality image]][Scrutinizer Master] | [![Code Quality][Quality 2.7 image]][Scrutinizer 2.7] | [![Code Quality][Quality 2.6 image]][Scrutinizer 2.6] | [![Code Quality][Quality develop image]][Scrutinizer develop] |
|
||||
| [![AppVeyor][AppVeyor master image]][AppVeyor master] | [![AppVeyor][AppVeyor 2.7 image]][AppVeyor 2.7] | | [![AppVeyor][AppVeyor develop image]][AppVeyor develop] |
|
||||
| [Master][Master] | [2.8][2.8] | [Develop][develop] |
|
||||
|:----------------:|:----------:|:------------------:|
|
||||
| [![Build status][Master image]][Master] | [![Build status][2.8 image]][2.8] | [![Build status][develop image]][develop] |
|
||||
| [![Build Status][ContinuousPHP image]][ContinuousPHP] | [![Build Status][ContinuousPHP 2.8 image]][ContinuousPHP] | [![Build Status][ContinuousPHP develop image]][ContinuousPHP] |
|
||||
| [![Code Coverage][Coverage image]][Scrutinizer Master] | [![Code Coverage][Coverage 2.8 image]][Scrutinizer 2.8] | [![Code Coverage][Coverage develop image]][Scrutinizer develop] |
|
||||
| [![Code Quality][Quality image]][Scrutinizer Master] | [![Code Quality][Quality 2.8 image]][Scrutinizer 2.8] | [![Code Quality][Quality develop image]][Scrutinizer develop] |
|
||||
| [![AppVeyor][AppVeyor master image]][AppVeyor master] | [![AppVeyor][AppVeyor 2.8 image]][AppVeyor 2.8] | [![AppVeyor][AppVeyor develop image]][AppVeyor develop] |
|
||||
|
||||
Powerful database abstraction layer with many features for database schema introspection, schema management and PDO abstraction.
|
||||
|
||||
@@ -26,20 +26,14 @@ Powerful database abstraction layer with many features for database schema intro
|
||||
[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
|
||||
[ContinuousPHP]: https://continuousphp.com/git-hub/doctrine/dbal
|
||||
[2.7 image]: https://img.shields.io/travis/doctrine/dbal/2.7.svg?style=flat-square
|
||||
[Coverage 2.7 image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/2.7.svg?style=flat-square
|
||||
[Quality 2.7 image]: https://img.shields.io/scrutinizer/g/doctrine/dbal/2.7.svg?style=flat-square
|
||||
[ContinuousPHP 2.7 image]: https://img.shields.io/continuousphp/git-hub/doctrine/dbal/2.7.svg?style=flat-square
|
||||
[2.7]: https://github.com/doctrine/dbal/tree/2.7
|
||||
[Scrutinizer 2.7]: https://scrutinizer-ci.com/g/doctrine/dbal/?branch=2.7
|
||||
[AppVeyor 2.7]: https://ci.appveyor.com/project/doctrine/dbal/branch/2.7
|
||||
[AppVeyor 2.7 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.7?svg=true
|
||||
[2.6 image]: https://img.shields.io/travis/doctrine/dbal/2.6.svg?style=flat-square
|
||||
[Coverage 2.6 image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/2.6.svg?style=flat-square
|
||||
[Quality 2.6 image]: https://img.shields.io/scrutinizer/g/doctrine/dbal/2.6.svg?style=flat-square
|
||||
[ContinuousPHP 2.6 image]: https://img.shields.io/continuousphp/git-hub/doctrine/dbal/2.6.svg?style=flat-square
|
||||
[2.6]: https://github.com/doctrine/dbal/tree/2.6
|
||||
[Scrutinizer 2.6]: https://scrutinizer-ci.com/g/doctrine/dbal/?branch=2.6
|
||||
[2.8 image]: https://img.shields.io/travis/doctrine/dbal/2.8.svg?style=flat-square
|
||||
[Coverage 2.8 image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/2.8.svg?style=flat-square
|
||||
[Quality 2.8 image]: https://img.shields.io/scrutinizer/g/doctrine/dbal/2.8.svg?style=flat-square
|
||||
[ContinuousPHP 2.8 image]: https://img.shields.io/continuousphp/git-hub/doctrine/dbal/2.8.svg?style=flat-square
|
||||
[2.8]: https://github.com/doctrine/dbal/tree/2.8
|
||||
[Scrutinizer 2.8]: https://scrutinizer-ci.com/g/doctrine/dbal/?branch=2.8
|
||||
[AppVeyor 2.8]: https://ci.appveyor.com/project/doctrine/dbal/branch/2.8
|
||||
[AppVeyor 2.8 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.8?svg=true
|
||||
[develop]: https://github.com/doctrine/dbal/tree/develop
|
||||
[develop image]: https://img.shields.io/travis/doctrine/dbal/develop.svg?style=flat-square
|
||||
[Coverage develop image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/dbal/develop.svg?style=flat-square
|
||||
|
31
vendor/doctrine/dbal/UPGRADE.md
vendored
31
vendor/doctrine/dbal/UPGRADE.md
vendored
@@ -1,3 +1,34 @@
|
||||
# Upgrade to 2.9
|
||||
|
||||
## Deprecated `Statement::fetchColumn()` with an invalid index
|
||||
|
||||
Calls to `Statement::fetchColumn()` with an invalid column index currently return `NULL`. In the future, such calls will result in a exception.
|
||||
|
||||
## Deprecated `Configuration::getFilterSchemaAssetsExpression()`, `::setFilterSchemaAssetsExpression()` and `AbstractSchemaManager::getFilterSchemaAssetsExpression()`.
|
||||
|
||||
Regular expression-based filters are hard to extend by combining together. Instead, you may use callback-based filers via `::getSchemaAssetsFilter()` and `::getSchemaAssetsFilter()`. Callbacks can use regular expressions internally.
|
||||
|
||||
## Deprecated `Doctrine\DBAL\Types\Type::getDefaultLength()`
|
||||
|
||||
This method was never used by DBAL internally. It is now deprecated and will be removed in DBAL 3.0.
|
||||
|
||||
## Deprecated `Doctrine\DBAL\Types\Type::__toString()`
|
||||
|
||||
Relying on string representation is discouraged and will be removed in DBAL 3.0.
|
||||
|
||||
## Deprecated `NULL` value of `$offset` in LIMIT queries
|
||||
|
||||
The `NULL` value of the `$offset` argument in `AbstractPlatform::(do)?ModifyLimitQuery()` methods is deprecated. If explicitly used in the method call, the absence of the offset should be indicated with a `0`.
|
||||
|
||||
## Deprecated dbal:import CLI command
|
||||
|
||||
The `dbal:import` CLI command has been deprecated since it only works with PDO-based drivers by relying on a non-documented behavior of the extension, and it's impossible to make it work with other drivers.
|
||||
Please use other database client applications for import, e.g.:
|
||||
|
||||
* For MySQL and MariaDB: `mysql [dbname] < data.sql`.
|
||||
* For PostgreSQL: `psql [dbname] < data.sql`.
|
||||
* For SQLite: `sqlite3 /path/to/file.db < data.sql`.
|
||||
|
||||
# Upgrade to 2.8
|
||||
|
||||
## Deprecated usage of DB-generated UUIDs
|
||||
|
0
vendor/doctrine/dbal/bin/doctrine-dbal
vendored
Normal file → Executable file
0
vendor/doctrine/dbal/bin/doctrine-dbal
vendored
Normal file → Executable file
33
vendor/doctrine/dbal/bin/doctrine-dbal.php
vendored
33
vendor/doctrine/dbal/bin/doctrine-dbal.php
vendored
@@ -1,29 +1,12 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
use Doctrine\DBAL\Tools\Console\ConsoleRunner;
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
|
||||
$files = array(__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php');
|
||||
$files = [__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php'];
|
||||
$loader = null;
|
||||
$cwd = getcwd();
|
||||
$directories = array($cwd, $cwd . DIRECTORY_SEPARATOR . 'config');
|
||||
$directories = [$cwd, $cwd . DIRECTORY_SEPARATOR . 'config'];
|
||||
$configFile = null;
|
||||
|
||||
foreach ($files as $file) {
|
||||
@@ -34,7 +17,7 @@ foreach ($files as $file) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $loader) {
|
||||
if (! $loader) {
|
||||
throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
|
||||
}
|
||||
|
||||
@@ -46,22 +29,22 @@ foreach ($directories as $directory) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! file_exists($configFile)) {
|
||||
if (! file_exists($configFile)) {
|
||||
ConsoleRunner::printCliConfigTemplate();
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( ! is_readable($configFile)) {
|
||||
if (! is_readable($configFile)) {
|
||||
echo 'Configuration file [' . $configFile . '] does not have read permission.' . PHP_EOL;
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$commands = array();
|
||||
$commands = [];
|
||||
$helperSet = require $configFile;
|
||||
|
||||
if ( ! $helperSet instanceof HelperSet) {
|
||||
if (! $helperSet instanceof HelperSet) {
|
||||
foreach ($GLOBALS as $helperSetCandidate) {
|
||||
if ($helperSetCandidate instanceof HelperSet) {
|
||||
$helperSet = $helperSetCandidate;
|
||||
|
29
vendor/doctrine/dbal/composer.json
vendored
29
vendor/doctrine/dbal/composer.json
vendored
@@ -1,9 +1,18 @@
|
||||
{
|
||||
"name": "doctrine/dbal",
|
||||
"type": "library",
|
||||
"description": "Database Abstraction Layer",
|
||||
"keywords": ["dbal", "database", "persistence", "queryobject"],
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.",
|
||||
"keywords": [
|
||||
"php",
|
||||
"mysql",
|
||||
"pgsql",
|
||||
"dbal",
|
||||
"database",
|
||||
"abstraction",
|
||||
"persistence",
|
||||
"queryobject"
|
||||
],
|
||||
"homepage": "https://www.doctrine-project.org/projects/dbal.html",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
|
||||
@@ -18,11 +27,10 @@
|
||||
"doctrine/event-manager": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^4.0",
|
||||
"doctrine/coding-standard": "^5.0",
|
||||
"jetbrains/phpstorm-stubs": "^2018.1.2",
|
||||
"phpstan/phpstan": "^0.10.1",
|
||||
"phpunit/phpunit": "^7.1.2",
|
||||
"phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5",
|
||||
"phpunit/phpunit": "^7.4",
|
||||
"symfony/console": "^2.0.5|^3.0|^4.0",
|
||||
"symfony/phpunit-bridge": "^3.4.5|^4.0.5"
|
||||
},
|
||||
@@ -34,18 +42,15 @@
|
||||
"sort-packages": true
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Doctrine\\DBAL\\": "lib/" }
|
||||
"psr-4": { "Doctrine\\DBAL\\": "lib/Doctrine/DBAL" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-0": { "Doctrine\\Tests\\": "tests/" }
|
||||
"psr-4": { "Doctrine\\Tests\\": "tests/Doctrine/Tests" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.8.x-dev",
|
||||
"dev-master": "2.9.x-dev",
|
||||
"dev-develop": "3.0.x-dev"
|
||||
}
|
||||
},
|
||||
"archive": {
|
||||
"exclude": ["!vendor", "tests", "*phpunit.xml", ".appveyor.yml", ".travis.yml", "build.xml", "build.properties", "composer.phar"]
|
||||
}
|
||||
}
|
||||
|
@@ -1,62 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
use ArrayIterator;
|
||||
use Doctrine\DBAL\Driver\ResultStatement;
|
||||
use Doctrine\DBAL\FetchMode;
|
||||
use InvalidArgumentException;
|
||||
use IteratorAggregate;
|
||||
use PDO;
|
||||
use function array_merge;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function reset;
|
||||
|
||||
class ArrayStatement implements \IteratorAggregate, ResultStatement
|
||||
class ArrayStatement implements IteratorAggregate, ResultStatement
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var mixed[] */
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $columnCount = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $num = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $defaultFetchMode = FetchMode::MIXED;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
if (count($data)) {
|
||||
$this->columnCount = count($data[0]);
|
||||
if (! count($data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->columnCount = count($data[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,7 +45,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
|
||||
*/
|
||||
public function closeCursor()
|
||||
{
|
||||
unset ($this->data);
|
||||
unset($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +62,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
|
||||
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
|
||||
{
|
||||
if ($arg2 !== null || $arg3 !== null) {
|
||||
throw new \InvalidArgumentException("Caching layer does not support 2nd/3rd argument to setFetchMode()");
|
||||
throw new InvalidArgumentException('Caching layer does not support 2nd/3rd argument to setFetchMode()');
|
||||
}
|
||||
|
||||
$this->defaultFetchMode = $fetchMode;
|
||||
@@ -96,13 +77,13 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
|
||||
{
|
||||
$data = $this->fetchAll();
|
||||
|
||||
return new \ArrayIterator($data);
|
||||
return new ArrayIterator($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
if (! isset($this->data[$this->num])) {
|
||||
return false;
|
||||
@@ -127,7 +108,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
|
||||
return reset($row);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Invalid fetch-style given for fetching result.');
|
||||
throw new InvalidArgumentException('Invalid fetch-style given for fetching result.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,36 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
/**
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @since 2.2
|
||||
*/
|
||||
class CacheException extends \Doctrine\DBAL\DBALException
|
||||
use Doctrine\DBAL\DBALException;
|
||||
|
||||
class CacheException extends DBALException
|
||||
{
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Cache\CacheException
|
||||
*/
|
||||
public static function noCacheKey()
|
||||
{
|
||||
return new self("No cache key was set.");
|
||||
return new self('No cache key was set.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,6 +19,6 @@ class CacheException extends \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
public static function noResultDriverConfigured()
|
||||
{
|
||||
return new self("Trying to cache a query but no result driver is configured.");
|
||||
return new self('Trying to cache a query but no result driver is configured.');
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
@@ -31,19 +14,13 @@ use function sha1;
|
||||
*/
|
||||
class QueryCacheProfile
|
||||
{
|
||||
/**
|
||||
* @var Cache|null
|
||||
*/
|
||||
/** @var Cache|null */
|
||||
private $resultCacheDriver;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $lifetime = 0;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
/** @var string|null */
|
||||
private $cacheKey;
|
||||
|
||||
/**
|
||||
@@ -90,12 +67,12 @@ class QueryCacheProfile
|
||||
/**
|
||||
* Generates the real cache key from query, params, types and connection parameters.
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $params
|
||||
* @param array $types
|
||||
* @param array $connectionParams
|
||||
* @param string $query
|
||||
* @param mixed[] $params
|
||||
* @param int[]|string[] $types
|
||||
* @param mixed[] $connectionParams
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function generateCacheKeys($query, $params, $types, array $connectionParams = [])
|
||||
{
|
||||
@@ -115,7 +92,6 @@ class QueryCacheProfile
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \Doctrine\DBAL\Cache\QueryCacheProfile
|
||||
*/
|
||||
public function setResultCacheDriver(Cache $cache)
|
||||
|
@@ -1,28 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
use Doctrine\DBAL\Driver\Statement;
|
||||
use Doctrine\DBAL\Driver\ResultStatement;
|
||||
use ArrayIterator;
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\DBAL\Driver\ResultStatement;
|
||||
use Doctrine\DBAL\Driver\Statement;
|
||||
use Doctrine\DBAL\FetchMode;
|
||||
use InvalidArgumentException;
|
||||
use IteratorAggregate;
|
||||
use PDO;
|
||||
use function array_merge;
|
||||
use function array_values;
|
||||
use function reset;
|
||||
@@ -40,32 +27,21 @@ use function reset;
|
||||
* Also you have to realize that the cache will load the whole result into memory at once to ensure 2.
|
||||
* This means that the memory usage for cached results might increase by using this feature.
|
||||
*/
|
||||
class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
class ResultCacheStatement implements IteratorAggregate, ResultStatement
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\Common\Cache\Cache
|
||||
*/
|
||||
/** @var Cache */
|
||||
private $resultCache;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $cacheKey;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $realKey;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $lifetime;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Driver\Statement
|
||||
*/
|
||||
/** @var Statement */
|
||||
private $statement;
|
||||
|
||||
/**
|
||||
@@ -75,30 +51,24 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
*/
|
||||
private $emptied = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var mixed[] */
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $defaultFetchMode = FetchMode::MIXED;
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Driver\Statement $stmt
|
||||
* @param \Doctrine\Common\Cache\Cache $resultCache
|
||||
* @param string $cacheKey
|
||||
* @param string $realKey
|
||||
* @param int $lifetime
|
||||
* @param string $cacheKey
|
||||
* @param string $realKey
|
||||
* @param int $lifetime
|
||||
*/
|
||||
public function __construct(Statement $stmt, Cache $resultCache, $cacheKey, $realKey, $lifetime)
|
||||
{
|
||||
$this->statement = $stmt;
|
||||
$this->statement = $stmt;
|
||||
$this->resultCache = $resultCache;
|
||||
$this->cacheKey = $cacheKey;
|
||||
$this->realKey = $realKey;
|
||||
$this->lifetime = $lifetime;
|
||||
$this->cacheKey = $cacheKey;
|
||||
$this->realKey = $realKey;
|
||||
$this->lifetime = $lifetime;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,16 +77,20 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
public function closeCursor()
|
||||
{
|
||||
$this->statement->closeCursor();
|
||||
if ($this->emptied && $this->data !== null) {
|
||||
$data = $this->resultCache->fetch($this->cacheKey);
|
||||
if ( ! $data) {
|
||||
$data = [];
|
||||
}
|
||||
$data[$this->realKey] = $this->data;
|
||||
|
||||
$this->resultCache->save($this->cacheKey, $data, $this->lifetime);
|
||||
unset($this->data);
|
||||
if (! $this->emptied || $this->data === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$data = $this->resultCache->fetch($this->cacheKey);
|
||||
if (! $data) {
|
||||
$data = [];
|
||||
}
|
||||
$data[$this->realKey] = $this->data;
|
||||
|
||||
$this->resultCache->save($this->cacheKey, $data, $this->lifetime);
|
||||
unset($this->data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,13 +118,13 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
{
|
||||
$data = $this->fetchAll();
|
||||
|
||||
return new \ArrayIterator($data);
|
||||
return new ArrayIterator($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
if ($this->data === null) {
|
||||
$this->data = [];
|
||||
@@ -179,7 +153,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
return reset($row);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Invalid fetch-style given for caching result.');
|
||||
throw new InvalidArgumentException('Invalid fetch-style given for caching result.');
|
||||
}
|
||||
|
||||
$this->emptied = true;
|
||||
@@ -192,12 +166,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
|
||||
*/
|
||||
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
|
||||
{
|
||||
$rows = [];
|
||||
while ($row = $this->fetch($fetchMode)) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
return $this->statement->fetchAll($fetchMode, $fetchArgument, $ctorArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Contains portable column case conversions.
|
||||
*/
|
||||
@@ -12,14 +14,14 @@ final class ColumnCase
|
||||
*
|
||||
* @see \PDO::CASE_UPPER
|
||||
*/
|
||||
public const UPPER = \PDO::CASE_UPPER;
|
||||
public const UPPER = PDO::CASE_UPPER;
|
||||
|
||||
/**
|
||||
* Convert column names to lower case.
|
||||
*
|
||||
* @see \PDO::CASE_LOWER
|
||||
*/
|
||||
public const LOWER = \PDO::CASE_LOWER;
|
||||
public const LOWER = PDO::CASE_LOWER;
|
||||
|
||||
/**
|
||||
* This class cannot be instantiated.
|
||||
|
@@ -1,34 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
use Doctrine\DBAL\Logging\SQLLogger;
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\DBAL\Logging\SQLLogger;
|
||||
use Doctrine\DBAL\Schema\AbstractAsset;
|
||||
use function preg_match;
|
||||
|
||||
/**
|
||||
* Configuration container for the Doctrine DBAL.
|
||||
*
|
||||
* @since 2.0
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @internal When adding a new configuration option just write a getter/setter
|
||||
* pair and add the option to the _attributes array with a proper default value.
|
||||
*/
|
||||
@@ -38,18 +19,16 @@ class Configuration
|
||||
* The attributes that are contained in the configuration.
|
||||
* Values are default values.
|
||||
*
|
||||
* @var array
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $_attributes = [];
|
||||
|
||||
/**
|
||||
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
|
||||
*
|
||||
* @param \Doctrine\DBAL\Logging\SQLLogger|null $logger
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSQLLogger(SQLLogger $logger = null)
|
||||
public function setSQLLogger(?SQLLogger $logger = null)
|
||||
{
|
||||
$this->_attributes['sqlLogger'] = $logger;
|
||||
}
|
||||
@@ -57,7 +36,7 @@ class Configuration
|
||||
/**
|
||||
* Gets the SQL logger that is used.
|
||||
*
|
||||
* @return \Doctrine\DBAL\Logging\SQLLogger|null
|
||||
* @return SQLLogger|null
|
||||
*/
|
||||
public function getSQLLogger()
|
||||
{
|
||||
@@ -67,7 +46,7 @@ class Configuration
|
||||
/**
|
||||
* Gets the cache driver implementation that is used for query result caching.
|
||||
*
|
||||
* @return \Doctrine\Common\Cache\Cache|null
|
||||
* @return Cache|null
|
||||
*/
|
||||
public function getResultCacheImpl()
|
||||
{
|
||||
@@ -77,8 +56,6 @@ class Configuration
|
||||
/**
|
||||
* Sets the cache driver implementation that is used for query result caching.
|
||||
*
|
||||
* @param \Doctrine\Common\Cache\Cache $cacheImpl
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setResultCacheImpl(Cache $cacheImpl)
|
||||
@@ -93,6 +70,8 @@ class Configuration
|
||||
* schema instances generated for the active connection when calling
|
||||
* {AbstractSchemaManager#createSchema()}.
|
||||
*
|
||||
* @deprecated Use Configuration::setSchemaAssetsFilter() instead
|
||||
*
|
||||
* @param string $filterExpression
|
||||
*
|
||||
* @return void
|
||||
@@ -100,11 +79,18 @@ class Configuration
|
||||
public function setFilterSchemaAssetsExpression($filterExpression)
|
||||
{
|
||||
$this->_attributes['filterSchemaAssetsExpression'] = $filterExpression;
|
||||
if ($filterExpression) {
|
||||
$this->_attributes['filterSchemaAssetsExpressionCallable'] = $this->buildSchemaAssetsFilterFromExpression($filterExpression);
|
||||
} else {
|
||||
$this->_attributes['filterSchemaAssetsExpressionCallable'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filter schema assets expression.
|
||||
*
|
||||
* @deprecated Use Configuration::getSchemaAssetsFilter() instead
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFilterSchemaAssetsExpression()
|
||||
@@ -112,6 +98,36 @@ class Configuration
|
||||
return $this->_attributes['filterSchemaAssetsExpression'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filterExpression
|
||||
*/
|
||||
private function buildSchemaAssetsFilterFromExpression($filterExpression) : callable
|
||||
{
|
||||
return static function ($assetName) use ($filterExpression) {
|
||||
if ($assetName instanceof AbstractAsset) {
|
||||
$assetName = $assetName->getName();
|
||||
}
|
||||
return preg_match($filterExpression, $assetName);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the callable to use to filter schema assets.
|
||||
*/
|
||||
public function setSchemaAssetsFilter(?callable $callable = null) : ?callable
|
||||
{
|
||||
$this->_attributes['filterSchemaAssetsExpression'] = null;
|
||||
return $this->_attributes['filterSchemaAssetsExpressionCallable'] = $callable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the callable to use to filter schema assets.
|
||||
*/
|
||||
public function getSchemaAssetsFilter() : ?callable
|
||||
{
|
||||
return $this->_attributes['filterSchemaAssetsExpressionCallable'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default auto-commit mode for connections.
|
||||
*
|
||||
@@ -119,21 +135,21 @@ class Configuration
|
||||
* transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either
|
||||
* the method commit or the method rollback. By default, new connections are in auto-commit mode.
|
||||
*
|
||||
* @param bool $autoCommit True to enable auto-commit mode; false to disable it.
|
||||
*
|
||||
* @see getAutoCommit
|
||||
*
|
||||
* @param bool $autoCommit True to enable auto-commit mode; false to disable it.
|
||||
*/
|
||||
public function setAutoCommit($autoCommit)
|
||||
{
|
||||
$this->_attributes['autoCommit'] = (boolean) $autoCommit;
|
||||
$this->_attributes['autoCommit'] = (bool) $autoCommit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default auto-commit mode for connections.
|
||||
*
|
||||
* @return bool True if auto-commit mode is enabled by default for connections, false otherwise.
|
||||
*
|
||||
* @see setAutoCommit
|
||||
*
|
||||
* @return bool True if auto-commit mode is enabled by default for connections, false otherwise.
|
||||
*/
|
||||
public function getAutoCommit()
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,29 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
/**
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com
|
||||
*/
|
||||
class ConnectionException extends DBALException
|
||||
{
|
||||
/**
|
||||
@@ -31,7 +9,7 @@ class ConnectionException extends DBALException
|
||||
*/
|
||||
public static function commitFailedRollbackOnly()
|
||||
{
|
||||
return new self("Transaction commit failed because the transaction has been marked for rollback only.");
|
||||
return new self('Transaction commit failed because the transaction has been marked for rollback only.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +17,7 @@ class ConnectionException extends DBALException
|
||||
*/
|
||||
public static function noActiveTransaction()
|
||||
{
|
||||
return new self("There is no active transaction.");
|
||||
return new self('There is no active transaction.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +25,7 @@ class ConnectionException extends DBALException
|
||||
*/
|
||||
public static function savepointsNotSupported()
|
||||
{
|
||||
return new self("Savepoints are not supported by this driver.");
|
||||
return new self('Savepoints are not supported by this driver.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,6 +33,6 @@ class ConnectionException extends DBALException
|
||||
*/
|
||||
public static function mayNotAlterNestedTransactionWithSavepointsInTransaction()
|
||||
{
|
||||
return new self("May not alter the nested transaction with savepoints behavior while a transaction is open.");
|
||||
return new self('May not alter the nested transaction with savepoints behavior while a transaction is open.');
|
||||
}
|
||||
}
|
||||
|
@@ -1,31 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Connections;
|
||||
|
||||
use Doctrine\Common\EventManager;
|
||||
use Doctrine\DBAL\Configuration;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\Connection as DriverConnection;
|
||||
use Doctrine\DBAL\Configuration;
|
||||
use Doctrine\Common\EventManager;
|
||||
use Doctrine\DBAL\Event\ConnectionEventArgs;
|
||||
use Doctrine\DBAL\Events;
|
||||
use InvalidArgumentException;
|
||||
use function array_rand;
|
||||
use function count;
|
||||
use function func_get_args;
|
||||
@@ -80,9 +64,6 @@ use function func_get_args;
|
||||
* ));
|
||||
*
|
||||
* You can also pass 'driverOptions' and any other documented option to each of this drivers to pass additional information.
|
||||
*
|
||||
* @author Lars Strojny <lstrojny@php.net>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class MasterSlaveConnection extends Connection
|
||||
{
|
||||
@@ -104,20 +85,17 @@ class MasterSlaveConnection extends Connection
|
||||
/**
|
||||
* Creates Master Slave Connection.
|
||||
*
|
||||
* @param array $params
|
||||
* @param \Doctrine\DBAL\Driver $driver
|
||||
* @param \Doctrine\DBAL\Configuration|null $config
|
||||
* @param \Doctrine\Common\EventManager|null $eventManager
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
|
||||
public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null)
|
||||
{
|
||||
if (! isset($params['slaves'], $params['master'])) {
|
||||
throw new \InvalidArgumentException('master or slaves configuration missing');
|
||||
throw new InvalidArgumentException('master or slaves configuration missing');
|
||||
}
|
||||
if (count($params['slaves']) == 0) {
|
||||
throw new \InvalidArgumentException('You have to configure at least one slaves.');
|
||||
if (count($params['slaves']) === 0) {
|
||||
throw new InvalidArgumentException('You have to configure at least one slaves.');
|
||||
}
|
||||
|
||||
$params['master']['driver'] = $params['driver'];
|
||||
@@ -149,13 +127,13 @@ class MasterSlaveConnection extends Connection
|
||||
$connectionName = $connectionName ?: 'slave';
|
||||
|
||||
if ($connectionName !== 'slave' && $connectionName !== 'master') {
|
||||
throw new \InvalidArgumentException("Invalid option to connect(), only master or slave allowed.");
|
||||
throw new InvalidArgumentException('Invalid option to connect(), only master or slave allowed.');
|
||||
}
|
||||
|
||||
// If we have a connection open, and this is not an explicit connection
|
||||
// change request, then abort right here, because we are already done.
|
||||
// This prevents writes to the slave in case of "keepSlave" option enabled.
|
||||
if (isset($this->_conn) && $this->_conn && !$requestedConnectionChange) {
|
||||
if (isset($this->_conn) && $this->_conn && ! $requestedConnectionChange) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -180,7 +158,7 @@ class MasterSlaveConnection extends Connection
|
||||
$this->connections['master'] = $this->_conn = $this->connectTo($connectionName);
|
||||
|
||||
// Set slave connection to master to avoid invalid reads
|
||||
if ( ! $this->keepSlave) {
|
||||
if (! $this->keepSlave) {
|
||||
$this->connections['slave'] = $this->connections['master'];
|
||||
}
|
||||
} else {
|
||||
@@ -210,15 +188,15 @@ class MasterSlaveConnection extends Connection
|
||||
|
||||
$connectionParams = $this->chooseConnectionConfiguration($connectionName, $params);
|
||||
|
||||
$user = $connectionParams['user'] ?? null;
|
||||
$user = $connectionParams['user'] ?? null;
|
||||
$password = $connectionParams['password'] ?? null;
|
||||
|
||||
return $this->_driver->connect($connectionParams, $user, $password, $driverOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $connectionName
|
||||
* @param array $params
|
||||
* @param string $connectionName
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -230,7 +208,7 @@ class MasterSlaveConnection extends Connection
|
||||
|
||||
$config = $params['slaves'][array_rand($params['slaves'])];
|
||||
|
||||
if ( ! isset($config['charset']) && isset($params['master']['charset'])) {
|
||||
if (! isset($config['charset']) && isset($params['master']['charset'])) {
|
||||
$config['charset'] = $params['master']['charset'];
|
||||
}
|
||||
|
||||
@@ -296,7 +274,7 @@ class MasterSlaveConnection extends Connection
|
||||
|
||||
parent::close();
|
||||
|
||||
$this->_conn = null;
|
||||
$this->_conn = null;
|
||||
$this->connections = ['master' => null, 'slave' => null];
|
||||
}
|
||||
|
||||
|
@@ -1,38 +1,26 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\DriverException as DriverExceptionInterface;
|
||||
use Doctrine\DBAL\Driver\ExceptionConverterDriver;
|
||||
use Doctrine\DBAL\Exception\DriverException;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use function array_map;
|
||||
use function bin2hex;
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function implode;
|
||||
use function is_object;
|
||||
use function is_resource;
|
||||
use function is_string;
|
||||
use function json_encode;
|
||||
use function sprintf;
|
||||
use function str_split;
|
||||
|
||||
class DBALException extends \Exception
|
||||
class DBALException extends Exception
|
||||
{
|
||||
/**
|
||||
* @param string $method
|
||||
@@ -41,14 +29,14 @@ class DBALException extends \Exception
|
||||
*/
|
||||
public static function notSupported($method)
|
||||
{
|
||||
return new self("Operation '$method' is not supported by platform.");
|
||||
return new self(sprintf("Operation '%s' is not supported by platform.", $method));
|
||||
}
|
||||
|
||||
public static function invalidPlatformSpecified() : self
|
||||
{
|
||||
return new self(
|
||||
"Invalid 'platform' option specified, need to give an instance of ".
|
||||
"\Doctrine\DBAL\Platforms\AbstractPlatform.");
|
||||
"Invalid 'platform' option specified, need to give an instance of " . AbstractPlatform::class . '.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,12 +44,12 @@ class DBALException extends \Exception
|
||||
*/
|
||||
public static function invalidPlatformType($invalidPlatform) : self
|
||||
{
|
||||
if (\is_object($invalidPlatform)) {
|
||||
if (is_object($invalidPlatform)) {
|
||||
return new self(
|
||||
sprintf(
|
||||
"Option 'platform' must be a subtype of '%s', instance of '%s' given",
|
||||
AbstractPlatform::class,
|
||||
\get_class($invalidPlatform)
|
||||
get_class($invalidPlatform)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -70,7 +58,7 @@ class DBALException extends \Exception
|
||||
sprintf(
|
||||
"Option 'platform' must be an object and subtype of '%s'. Got '%s'",
|
||||
AbstractPlatform::class,
|
||||
\gettype($invalidPlatform)
|
||||
gettype($invalidPlatform)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -101,8 +89,8 @@ class DBALException extends \Exception
|
||||
public static function invalidPdoInstance()
|
||||
{
|
||||
return new self(
|
||||
"The 'pdo' option was used in DriverManager::getConnection() but no ".
|
||||
"instance of PDO was given."
|
||||
"The 'pdo' option was used in DriverManager::getConnection() but no " .
|
||||
'instance of PDO was given.'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -117,70 +105,67 @@ class DBALException extends \Exception
|
||||
return new self(
|
||||
sprintf(
|
||||
"The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme " .
|
||||
"is given to DriverManager::getConnection(). Given URL: %s",
|
||||
'is given to DriverManager::getConnection(). Given URL: %s',
|
||||
$url
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return new self("The options 'driver' or 'driverClass' are mandatory if no PDO ".
|
||||
"instance is given to DriverManager::getConnection().");
|
||||
return new self("The options 'driver' or 'driverClass' are mandatory if no PDO " .
|
||||
'instance is given to DriverManager::getConnection().');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $unknownDriverName
|
||||
* @param array $knownDrivers
|
||||
* @param string $unknownDriverName
|
||||
* @param string[] $knownDrivers
|
||||
*
|
||||
* @return \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
public static function unknownDriver($unknownDriverName, array $knownDrivers)
|
||||
{
|
||||
return new self("The given 'driver' ".$unknownDriverName." is unknown, ".
|
||||
"Doctrine currently supports only the following drivers: ".implode(", ", $knownDrivers));
|
||||
return new self("The given 'driver' " . $unknownDriverName . ' is unknown, ' .
|
||||
'Doctrine currently supports only the following drivers: ' . implode(', ', $knownDrivers));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Driver $driver
|
||||
* @param \Exception $driverEx
|
||||
* @param string $sql
|
||||
* @param array $params
|
||||
* @param Exception $driverEx
|
||||
* @param string $sql
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
public static function driverExceptionDuringQuery(Driver $driver, \Exception $driverEx, $sql, array $params = [])
|
||||
public static function driverExceptionDuringQuery(Driver $driver, Throwable $driverEx, $sql, array $params = [])
|
||||
{
|
||||
$msg = "An exception occurred while executing '".$sql."'";
|
||||
$msg = "An exception occurred while executing '" . $sql . "'";
|
||||
if ($params) {
|
||||
$msg .= " with params " . self::formatParameters($params);
|
||||
$msg .= ' with params ' . self::formatParameters($params);
|
||||
}
|
||||
$msg .= ":\n\n".$driverEx->getMessage();
|
||||
$msg .= ":\n\n" . $driverEx->getMessage();
|
||||
|
||||
return static::wrapException($driver, $driverEx, $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Driver $driver
|
||||
* @param \Exception $driverEx
|
||||
* @param Exception $driverEx
|
||||
*
|
||||
* @return \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
public static function driverException(Driver $driver, \Exception $driverEx)
|
||||
public static function driverException(Driver $driver, Throwable $driverEx)
|
||||
{
|
||||
return static::wrapException($driver, $driverEx, "An exception occurred in driver: " . $driverEx->getMessage());
|
||||
return static::wrapException($driver, $driverEx, 'An exception occurred in driver: ' . $driverEx->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Driver $driver
|
||||
* @param \Exception $driverEx
|
||||
* @param Exception $driverEx
|
||||
*
|
||||
* @return \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
private static function wrapException(Driver $driver, \Exception $driverEx, $msg)
|
||||
private static function wrapException(Driver $driver, Throwable $driverEx, $msg)
|
||||
{
|
||||
if ($driverEx instanceof Exception\DriverException) {
|
||||
if ($driverEx instanceof DriverException) {
|
||||
return $driverEx;
|
||||
}
|
||||
if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof Driver\DriverException) {
|
||||
if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof DriverExceptionInterface) {
|
||||
return $driver->convertException($msg, $driverEx);
|
||||
}
|
||||
|
||||
@@ -191,20 +176,20 @@ class DBALException extends \Exception
|
||||
* Returns a human-readable representation of an array of parameters.
|
||||
* This properly handles binary data by returning a hex representation.
|
||||
*
|
||||
* @param array $params
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function formatParameters(array $params)
|
||||
{
|
||||
return '[' . implode(', ', array_map(function ($param) {
|
||||
return '[' . implode(', ', array_map(static function ($param) {
|
||||
if (is_resource($param)) {
|
||||
return (string) $param;
|
||||
}
|
||||
|
||||
|
||||
$json = @json_encode($param);
|
||||
|
||||
if (! is_string($json) || $json == 'null' && is_string($param)) {
|
||||
if (! is_string($json) || $json === 'null' && is_string($param)) {
|
||||
// JSON encoding failed, this is not a UTF-8 string.
|
||||
return '"\x' . implode('\x', str_split(bin2hex($param), 2)) . '"';
|
||||
}
|
||||
@@ -220,8 +205,8 @@ class DBALException extends \Exception
|
||||
*/
|
||||
public static function invalidWrapperClass($wrapperClass)
|
||||
{
|
||||
return new self("The given 'wrapperClass' ".$wrapperClass." has to be a ".
|
||||
"subtype of \Doctrine\DBAL\Connection.");
|
||||
return new self("The given 'wrapperClass' " . $wrapperClass . ' has to be a ' .
|
||||
'subtype of \Doctrine\DBAL\Connection.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,8 +216,7 @@ class DBALException extends \Exception
|
||||
*/
|
||||
public static function invalidDriverClass($driverClass)
|
||||
{
|
||||
return new self("The given 'driverClass' ".$driverClass." has to implement the ".
|
||||
"\Doctrine\DBAL\Driver interface.");
|
||||
return new self("The given 'driverClass' " . $driverClass . ' has to implement the ' . Driver::class . ' interface.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,7 +226,7 @@ class DBALException extends \Exception
|
||||
*/
|
||||
public static function invalidTableName($tableName)
|
||||
{
|
||||
return new self("Invalid table name specified: ".$tableName);
|
||||
return new self('Invalid table name specified: ' . $tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,7 +236,7 @@ class DBALException extends \Exception
|
||||
*/
|
||||
public static function noColumnsSpecifiedForTable($tableName)
|
||||
{
|
||||
return new self("No columns specified for table ".$tableName);
|
||||
return new self('No columns specified for table ' . $tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,7 +244,7 @@ class DBALException extends \Exception
|
||||
*/
|
||||
public static function limitOffsetInvalid()
|
||||
{
|
||||
return new self("Invalid Offset in Limit Query, it has to be larger than or equal to 0.");
|
||||
return new self('Invalid Offset in Limit Query, it has to be larger than or equal to 0.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +254,7 @@ class DBALException extends \Exception
|
||||
*/
|
||||
public static function typeExists($name)
|
||||
{
|
||||
return new self('Type '.$name.' already exists.');
|
||||
return new self('Type ' . $name . ' already exists.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,14 +264,13 @@ class DBALException extends \Exception
|
||||
*/
|
||||
public static function unknownColumnType($name)
|
||||
{
|
||||
return new self('Unknown column type "'.$name.'" requested. Any Doctrine type that you use has ' .
|
||||
return new self('Unknown column type "' . $name . '" requested. Any Doctrine type that you use has ' .
|
||||
'to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the ' .
|
||||
'known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database ' .
|
||||
'introspection then you might have forgotten to register all database types for a Doctrine Type. Use ' .
|
||||
'AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement ' .
|
||||
'Type#getMappedDatabaseTypes(). If the type name is empty you might ' .
|
||||
'have a problem with the cache or forgot some mapping information.'
|
||||
);
|
||||
'have a problem with the cache or forgot some mapping information.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,6 +280,6 @@ class DBALException extends \Exception
|
||||
*/
|
||||
public static function typeNotFound($name)
|
||||
{
|
||||
return new self('Type to be overwritten '.$name.' does not exist.');
|
||||
return new self('Type to be overwritten ' . $name . ' does not exist.');
|
||||
}
|
||||
}
|
||||
|
@@ -1,39 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
||||
|
||||
/**
|
||||
* Driver interface.
|
||||
* Interface that all DBAL drivers must implement.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
interface Driver
|
||||
{
|
||||
/**
|
||||
* Attempts to create a connection with the database.
|
||||
*
|
||||
* @param array $params All connection parameters passed by the user.
|
||||
* @param mixed[] $params All connection parameters passed by the user.
|
||||
* @param string|null $username The username to use when connecting.
|
||||
* @param string|null $password The password to use when connecting.
|
||||
* @param array $driverOptions The driver options to use when connecting.
|
||||
* @param mixed[] $driverOptions The driver options to use when connecting.
|
||||
*
|
||||
* @return \Doctrine\DBAL\Driver\Connection The database connection.
|
||||
*/
|
||||
@@ -43,7 +27,7 @@ interface Driver
|
||||
* Gets the DatabasePlatform instance that provides all the metadata about
|
||||
* the platform this driver connects to.
|
||||
*
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
|
||||
* @return AbstractPlatform The database platform.
|
||||
*/
|
||||
public function getDatabasePlatform();
|
||||
|
||||
@@ -51,9 +35,7 @@ interface Driver
|
||||
* Gets the SchemaManager that can be used to inspect and change the underlying
|
||||
* database schema of the platform this driver connects to.
|
||||
*
|
||||
* @param \Doctrine\DBAL\Connection $conn
|
||||
*
|
||||
* @return \Doctrine\DBAL\Schema\AbstractSchemaManager
|
||||
* @return AbstractSchemaManager
|
||||
*/
|
||||
public function getSchemaManager(Connection $conn);
|
||||
|
||||
@@ -67,8 +49,6 @@ interface Driver
|
||||
/**
|
||||
* Gets the name of the database connected to for this driver.
|
||||
*
|
||||
* @param \Doctrine\DBAL\Connection $conn
|
||||
*
|
||||
* @return string The name of the database.
|
||||
*/
|
||||
public function getDatabase(Connection $conn);
|
||||
|
@@ -1,41 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Platforms\DB2Platform;
|
||||
use Doctrine\DBAL\Schema\DB2SchemaManager;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for IBM DB2 based drivers.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
abstract class AbstractDB2Driver implements Driver
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDatabase(\Doctrine\DBAL\Connection $conn)
|
||||
public function getDatabase(Connection $conn)
|
||||
{
|
||||
$params = $conn->getParams();
|
||||
|
||||
@@ -53,7 +33,7 @@ abstract class AbstractDB2Driver implements Driver
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
|
||||
public function getSchemaManager(Connection $conn)
|
||||
{
|
||||
return new DB2SchemaManager($conn);
|
||||
}
|
||||
|
@@ -1,32 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@link DriverException} interface.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
abstract class AbstractDriverException extends \Exception implements DriverException
|
||||
abstract class AbstractDriverException extends Exception implements DriverException
|
||||
{
|
||||
/**
|
||||
* The driver specific error code.
|
||||
@@ -43,8 +24,6 @@ abstract class AbstractDriverException extends \Exception implements DriverExcep
|
||||
private $sqlState;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message The driver error message.
|
||||
* @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any.
|
||||
* @param int|string|null $errorCode The driver specific error code if any.
|
||||
|
@@ -1,24 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Exception;
|
||||
@@ -34,10 +18,6 @@ use function version_compare;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for MySQL based drivers.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver
|
||||
{
|
||||
@@ -133,7 +113,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
|
||||
*/
|
||||
public function createDatabasePlatformForVersion($version)
|
||||
{
|
||||
$mariadb = false !== stripos($version, 'mariadb');
|
||||
$mariadb = stripos($version, 'mariadb') !== false;
|
||||
if ($mariadb && version_compare($this->getMariaDbMysqlVersionNumber($version), '10.2.7', '>=')) {
|
||||
return new MariaDb1027Platform();
|
||||
}
|
||||
@@ -156,11 +136,12 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
|
||||
* returned by Oracle MySQL servers.
|
||||
*
|
||||
* @param string $versionString Version string returned by the driver, i.e. '5.7.10'
|
||||
*
|
||||
* @throws DBALException
|
||||
*/
|
||||
private function getOracleMysqlVersionNumber(string $versionString) : string
|
||||
{
|
||||
if ( ! preg_match(
|
||||
if (! preg_match(
|
||||
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/',
|
||||
$versionString,
|
||||
$versionParts
|
||||
@@ -174,7 +155,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
|
||||
$minorVersion = $versionParts['minor'] ?? 0;
|
||||
$patchVersion = $versionParts['patch'] ?? null;
|
||||
|
||||
if ('5' === $majorVersion && '7' === $minorVersion && null === $patchVersion) {
|
||||
if ($majorVersion === '5' && $minorVersion === '7' && $patchVersion === null) {
|
||||
$patchVersion = '9';
|
||||
}
|
||||
|
||||
@@ -186,11 +167,12 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
|
||||
* that starts with the prefix '5.5.5-'
|
||||
*
|
||||
* @param string $versionString Version string as returned by mariadb server, i.e. '5.5.5-Mariadb-10.0.8-xenial'
|
||||
*
|
||||
* @throws DBALException
|
||||
*/
|
||||
private function getMariaDbMysqlVersionNumber(string $versionString) : string
|
||||
{
|
||||
if ( ! preg_match(
|
||||
if (! preg_match(
|
||||
'/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i',
|
||||
$versionString,
|
||||
$versionParts
|
||||
@@ -207,7 +189,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDatabase(\Doctrine\DBAL\Connection $conn)
|
||||
public function getDatabase(Connection $conn)
|
||||
{
|
||||
$params = $conn->getParams();
|
||||
|
||||
@@ -216,6 +198,7 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return MySqlPlatform
|
||||
*/
|
||||
public function getDatabasePlatform()
|
||||
@@ -225,9 +208,10 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return MySqlSchemaManager
|
||||
*/
|
||||
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
|
||||
public function getSchemaManager(Connection $conn)
|
||||
{
|
||||
return new MySqlSchemaManager($conn);
|
||||
}
|
||||
|
@@ -1,35 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Platforms\OraclePlatform;
|
||||
use Doctrine\DBAL\Schema\OracleSchemaManager;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for Oracle based drivers.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
|
||||
{
|
||||
@@ -79,7 +60,7 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDatabase(\Doctrine\DBAL\Connection $conn)
|
||||
public function getDatabase(Connection $conn)
|
||||
{
|
||||
$params = $conn->getParams();
|
||||
|
||||
@@ -97,7 +78,7 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
|
||||
public function getSchemaManager(Connection $conn)
|
||||
{
|
||||
return new OracleSchemaManager($conn);
|
||||
}
|
||||
@@ -105,51 +86,12 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
|
||||
/**
|
||||
* Returns an appropriate Easy Connect String for the given parameters.
|
||||
*
|
||||
* @param array $params The connection parameters to return the Easy Connect STring for.
|
||||
* @param mixed[] $params The connection parameters to return the Easy Connect String for.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @link https://docs.oracle.com/database/121/NETAG/naming.htm
|
||||
*/
|
||||
protected function getEasyConnectString(array $params)
|
||||
{
|
||||
if ( ! empty($params['connectstring'])) {
|
||||
return $params['connectstring'];
|
||||
}
|
||||
|
||||
if ( ! empty($params['host'])) {
|
||||
if ( ! isset($params['port'])) {
|
||||
$params['port'] = 1521;
|
||||
}
|
||||
|
||||
$serviceName = $params['dbname'];
|
||||
|
||||
if ( ! empty($params['servicename'])) {
|
||||
$serviceName = $params['servicename'];
|
||||
}
|
||||
|
||||
$service = 'SID=' . $serviceName;
|
||||
$pooled = '';
|
||||
$instance = '';
|
||||
|
||||
if (isset($params['service']) && $params['service'] == true) {
|
||||
$service = 'SERVICE_NAME=' . $serviceName;
|
||||
}
|
||||
|
||||
if (isset($params['instancename']) && ! empty($params['instancename'])) {
|
||||
$instance = '(INSTANCE_NAME = ' . $params['instancename'] . ')';
|
||||
}
|
||||
|
||||
if (isset($params['pooled']) && $params['pooled'] == true) {
|
||||
$pooled = '(SERVER=POOLED)';
|
||||
}
|
||||
|
||||
return '(DESCRIPTION=' .
|
||||
'(ADDRESS=(PROTOCOL=TCP)(HOST=' . $params['host'] . ')(PORT=' . $params['port'] . '))' .
|
||||
'(CONNECT_DATA=(' . $service . ')' . $instance . $pooled . '))';
|
||||
|
||||
}
|
||||
|
||||
return $params['dbname'] ?? '';
|
||||
return (string) EasyConnectString::fromConnectionParameters($params);
|
||||
}
|
||||
}
|
||||
|
121
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php
vendored
Normal file
121
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\AbstractOracleDriver;
|
||||
|
||||
use function implode;
|
||||
use function is_array;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Represents an Oracle Easy Connect string
|
||||
*
|
||||
* @link https://docs.oracle.com/database/121/NETAG/naming.htm
|
||||
*/
|
||||
final class EasyConnectString
|
||||
{
|
||||
/** @var string */
|
||||
private $string;
|
||||
|
||||
private function __construct(string $string)
|
||||
{
|
||||
$this->string = $string;
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object from an array representation
|
||||
*
|
||||
* @param mixed[] $params
|
||||
*/
|
||||
public static function fromArray(array $params) : self
|
||||
{
|
||||
return new self(self::renderParams($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object from the given DBAL connection parameters.
|
||||
*
|
||||
* @param mixed[] $params
|
||||
*/
|
||||
public static function fromConnectionParameters(array $params) : self
|
||||
{
|
||||
if (! empty($params['connectstring'])) {
|
||||
return new self($params['connectstring']);
|
||||
}
|
||||
|
||||
if (empty($params['host'])) {
|
||||
return new self($params['dbname'] ?? '');
|
||||
}
|
||||
|
||||
$connectData = [];
|
||||
|
||||
if (isset($params['servicename']) || isset($params['dbname'])) {
|
||||
$serviceKey = 'SID';
|
||||
|
||||
if (! empty($params['service'])) {
|
||||
$serviceKey = 'SERVICE_NAME';
|
||||
}
|
||||
|
||||
$serviceName = $params['servicename'] ?? $params['dbname'];
|
||||
|
||||
$connectData[$serviceKey] = $serviceName;
|
||||
}
|
||||
|
||||
if (! empty($params['instancename'])) {
|
||||
$connectData['INSTANCE_NAME'] = $params['instancename'];
|
||||
}
|
||||
|
||||
if (! empty($params['pooled'])) {
|
||||
$connectData['SERVER'] = 'POOLED';
|
||||
}
|
||||
|
||||
return self::fromArray([
|
||||
'DESCRIPTION' => [
|
||||
'ADDRESS' => [
|
||||
'PROTOCOL' => 'TCP',
|
||||
'HOST' => $params['host'],
|
||||
'PORT' => $params['port'] ?? 1521,
|
||||
],
|
||||
'CONNECT_DATA' => $connectData,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $params
|
||||
*/
|
||||
private static function renderParams(array $params) : string
|
||||
{
|
||||
$chunks = [];
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
$string = self::renderValue($value);
|
||||
|
||||
if ($string === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$chunks[] = sprintf('(%s=%s)', $key, $string);
|
||||
}
|
||||
|
||||
return implode('', $chunks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
private static function renderValue($value) : string
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return self::renderParams($value);
|
||||
}
|
||||
|
||||
return (string) $value;
|
||||
}
|
||||
}
|
@@ -1,24 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Exception;
|
||||
@@ -35,10 +19,6 @@ use function version_compare;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for PostgreSQL based drivers.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver
|
||||
{
|
||||
@@ -104,7 +84,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
|
||||
*/
|
||||
public function createDatabasePlatformForVersion($version)
|
||||
{
|
||||
if ( ! preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts)) {
|
||||
if (! preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts)) {
|
||||
throw DBALException::invalidPlatformVersionSpecified(
|
||||
$version,
|
||||
'<major_version>.<minor_version>.<patch_version>'
|
||||
@@ -116,7 +96,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
|
||||
$patchVersion = $versionParts['patch'] ?? 0;
|
||||
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
|
||||
|
||||
switch(true) {
|
||||
switch (true) {
|
||||
case version_compare($version, '10.0', '>='):
|
||||
return new PostgreSQL100Platform();
|
||||
case version_compare($version, '9.4', '>='):
|
||||
@@ -133,7 +113,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDatabase(\Doctrine\DBAL\Connection $conn)
|
||||
public function getDatabase(Connection $conn)
|
||||
{
|
||||
$params = $conn->getParams();
|
||||
|
||||
@@ -151,7 +131,7 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
|
||||
public function getSchemaManager(Connection $conn)
|
||||
{
|
||||
return new PostgreSqlSchemaManager($conn);
|
||||
}
|
||||
|
@@ -1,24 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Exception;
|
||||
@@ -33,10 +17,6 @@ use function version_compare;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for SAP Sybase SQL Anywhere based drivers.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver
|
||||
{
|
||||
@@ -90,7 +70,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
|
||||
*/
|
||||
public function createDatabasePlatformForVersion($version)
|
||||
{
|
||||
if ( ! preg_match(
|
||||
if (! preg_match(
|
||||
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/',
|
||||
$version,
|
||||
$versionParts
|
||||
@@ -107,7 +87,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
|
||||
$buildVersion = $versionParts['build'] ?? 0;
|
||||
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion . '.' . $buildVersion;
|
||||
|
||||
switch(true) {
|
||||
switch (true) {
|
||||
case version_compare($version, '16', '>='):
|
||||
return new SQLAnywhere16Platform();
|
||||
case version_compare($version, '12', '>='):
|
||||
@@ -122,7 +102,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDatabase(\Doctrine\DBAL\Connection $conn)
|
||||
public function getDatabase(Connection $conn)
|
||||
{
|
||||
$params = $conn->getParams();
|
||||
|
||||
@@ -140,7 +120,7 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
|
||||
public function getSchemaManager(Connection $conn)
|
||||
{
|
||||
return new SQLAnywhereSchemaManager($conn);
|
||||
}
|
||||
|
@@ -1,24 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Platforms\SQLServer2005Platform;
|
||||
@@ -32,10 +16,6 @@ use function version_compare;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for Microsoft SQL Server based drivers.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDriver
|
||||
{
|
||||
@@ -44,7 +24,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
|
||||
*/
|
||||
public function createDatabasePlatformForVersion($version)
|
||||
{
|
||||
if ( ! preg_match(
|
||||
if (! preg_match(
|
||||
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/',
|
||||
$version,
|
||||
$versionParts
|
||||
@@ -61,7 +41,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
|
||||
$buildVersion = $versionParts['build'] ?? 0;
|
||||
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion . '.' . $buildVersion;
|
||||
|
||||
switch(true) {
|
||||
switch (true) {
|
||||
case version_compare($version, '11.00.2100', '>='):
|
||||
return new SQLServer2012Platform();
|
||||
case version_compare($version, '10.00.1600', '>='):
|
||||
@@ -76,7 +56,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDatabase(\Doctrine\DBAL\Connection $conn)
|
||||
public function getDatabase(Connection $conn)
|
||||
{
|
||||
$params = $conn->getParams();
|
||||
|
||||
@@ -94,8 +74,7 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
|
||||
public function getSchemaManager(Connection $conn)
|
||||
{
|
||||
return new SQLServerSchemaManager($conn);
|
||||
}
|
||||
|
@@ -1,24 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
||||
@@ -27,10 +11,6 @@ use function strpos;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for SQLite based drivers.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver
|
||||
{
|
||||
@@ -93,7 +73,7 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDatabase(\Doctrine\DBAL\Connection $conn)
|
||||
public function getDatabase(Connection $conn)
|
||||
{
|
||||
$params = $conn->getParams();
|
||||
|
||||
@@ -111,7 +91,7 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
|
||||
public function getSchemaManager(Connection $conn)
|
||||
{
|
||||
return new SqliteSchemaManager($conn);
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
@@ -26,8 +9,6 @@ use Doctrine\DBAL\ParameterType;
|
||||
* Driver connections must implement this interface.
|
||||
*
|
||||
* This resembles (a subset of) the PDO interface.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
interface Connection
|
||||
{
|
||||
@@ -43,7 +24,7 @@ interface Connection
|
||||
/**
|
||||
* Executes an SQL statement, returning a result set as a Statement object.
|
||||
*
|
||||
* @return \Doctrine\DBAL\Driver\Statement
|
||||
* @return Statement
|
||||
*/
|
||||
public function query();
|
||||
|
||||
@@ -106,7 +87,7 @@ interface Connection
|
||||
/**
|
||||
* Returns extended error information associated with the last operation on the database handle.
|
||||
*
|
||||
* @return array
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function errorInfo();
|
||||
}
|
||||
|
@@ -1,35 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Contract for a driver exception.
|
||||
*
|
||||
* Driver exceptions provide the SQLSTATE of the driver
|
||||
* and the driver specific error code at the time the error occurred.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
interface DriverException extends \Throwable
|
||||
interface DriverException extends Throwable
|
||||
{
|
||||
/**
|
||||
* Returns the driver specific error code if available.
|
||||
|
@@ -1,30 +1,11 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\DrizzlePDOMySql;
|
||||
|
||||
use Doctrine\DBAL\Driver\PDOConnection;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
|
||||
/**
|
||||
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
|
||||
*/
|
||||
class Connection extends \Doctrine\DBAL\Driver\PDOConnection
|
||||
class Connection extends PDOConnection
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\DrizzlePDOMySql;
|
||||
|
||||
@@ -24,8 +7,6 @@ use Doctrine\DBAL\Schema\DrizzleSchemaManager;
|
||||
|
||||
/**
|
||||
* Drizzle driver using PDO MySql.
|
||||
*
|
||||
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
|
||||
*/
|
||||
class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver
|
||||
{
|
||||
@@ -34,14 +15,12 @@ class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver
|
||||
*/
|
||||
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
|
||||
{
|
||||
$conn = new Connection(
|
||||
return new Connection(
|
||||
$this->constructPdoDsn($params),
|
||||
$username,
|
||||
$password,
|
||||
$driverOptions
|
||||
);
|
||||
|
||||
return $conn;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,31 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
/**
|
||||
* Contract for a driver that is capable of converting DBAL driver exceptions into standardized DBAL driver exceptions.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
interface ExceptionConverterDriver
|
||||
{
|
||||
@@ -35,8 +13,8 @@ interface ExceptionConverterDriver
|
||||
* It evaluates the vendor specific error code and SQLSTATE and transforms
|
||||
* it into a unified {@link Doctrine\DBAL\Exception\DriverException} subclass.
|
||||
*
|
||||
* @param string $message The DBAL exception message to use.
|
||||
* @param \Doctrine\DBAL\Driver\DriverException $exception The DBAL driver exception to convert.
|
||||
* @param string $message The DBAL exception message to use.
|
||||
* @param DriverException $exception The DBAL driver exception to convert.
|
||||
*
|
||||
* @return \Doctrine\DBAL\Exception\DriverException An instance of one of the DriverException subclasses.
|
||||
*/
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
@@ -43,29 +26,27 @@ use function func_get_args;
|
||||
|
||||
class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
{
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
private $_conn = null;
|
||||
/** @var resource */
|
||||
private $conn = null;
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param array $driverOptions
|
||||
* @param mixed[] $params
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param mixed[] $driverOptions
|
||||
*
|
||||
* @throws \Doctrine\DBAL\Driver\IBMDB2\DB2Exception
|
||||
* @throws DB2Exception
|
||||
*/
|
||||
public function __construct(array $params, $username, $password, $driverOptions = [])
|
||||
{
|
||||
$isPersistent = (isset($params['persistent']) && $params['persistent'] == true);
|
||||
$isPersistent = (isset($params['persistent']) && $params['persistent'] === true);
|
||||
|
||||
if ($isPersistent) {
|
||||
$this->_conn = db2_pconnect($params['dbname'], $username, $password, $driverOptions);
|
||||
$this->conn = db2_pconnect($params['dbname'], $username, $password, $driverOptions);
|
||||
} else {
|
||||
$this->_conn = db2_connect($params['dbname'], $username, $password, $driverOptions);
|
||||
$this->conn = db2_connect($params['dbname'], $username, $password, $driverOptions);
|
||||
}
|
||||
if ( ! $this->_conn) {
|
||||
if (! $this->conn) {
|
||||
throw new DB2Exception(db2_conn_errormsg());
|
||||
}
|
||||
}
|
||||
@@ -76,7 +57,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
public function getServerVersion()
|
||||
{
|
||||
/** @var stdClass $serverInfo */
|
||||
$serverInfo = db2_server_info($this->_conn);
|
||||
$serverInfo = db2_server_info($this->conn);
|
||||
|
||||
return $serverInfo->DBMS_VER;
|
||||
}
|
||||
@@ -94,8 +75,8 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function prepare($sql)
|
||||
{
|
||||
$stmt = @db2_prepare($this->_conn, $sql);
|
||||
if ( ! $stmt) {
|
||||
$stmt = @db2_prepare($this->conn, $sql);
|
||||
if (! $stmt) {
|
||||
throw new DB2Exception(db2_stmt_errormsg());
|
||||
}
|
||||
|
||||
@@ -108,7 +89,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
public function query()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$sql = $args[0];
|
||||
$sql = $args[0];
|
||||
$stmt = $this->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
@@ -126,7 +107,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
return $input;
|
||||
}
|
||||
|
||||
return "'".$input."'";
|
||||
return "'" . $input . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,9 +115,9 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function exec($statement)
|
||||
{
|
||||
$stmt = @db2_exec($this->_conn, $statement);
|
||||
$stmt = @db2_exec($this->conn, $statement);
|
||||
|
||||
if (false === $stmt) {
|
||||
if ($stmt === false) {
|
||||
throw new DB2Exception(db2_stmt_errormsg());
|
||||
}
|
||||
|
||||
@@ -148,7 +129,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function lastInsertId($name = null)
|
||||
{
|
||||
return db2_last_insert_id($this->_conn);
|
||||
return db2_last_insert_id($this->conn);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +137,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
db2_autocommit($this->_conn, DB2_AUTOCOMMIT_OFF);
|
||||
db2_autocommit($this->conn, DB2_AUTOCOMMIT_OFF);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,10 +145,10 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
if (!db2_commit($this->_conn)) {
|
||||
throw new DB2Exception(db2_conn_errormsg($this->_conn));
|
||||
if (! db2_commit($this->conn)) {
|
||||
throw new DB2Exception(db2_conn_errormsg($this->conn));
|
||||
}
|
||||
db2_autocommit($this->_conn, DB2_AUTOCOMMIT_ON);
|
||||
db2_autocommit($this->conn, DB2_AUTOCOMMIT_ON);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,10 +156,10 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function rollBack()
|
||||
{
|
||||
if (!db2_rollback($this->_conn)) {
|
||||
throw new DB2Exception(db2_conn_errormsg($this->_conn));
|
||||
if (! db2_rollback($this->conn)) {
|
||||
throw new DB2Exception(db2_conn_errormsg($this->conn));
|
||||
}
|
||||
db2_autocommit($this->_conn, DB2_AUTOCOMMIT_ON);
|
||||
db2_autocommit($this->conn, DB2_AUTOCOMMIT_ON);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +167,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function errorCode()
|
||||
{
|
||||
return db2_conn_error($this->_conn);
|
||||
return db2_conn_error($this->conn);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,7 +176,7 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
public function errorInfo()
|
||||
{
|
||||
return [
|
||||
0 => db2_conn_errormsg($this->_conn),
|
||||
0 => db2_conn_errormsg($this->conn),
|
||||
1 => $this->errorCode(),
|
||||
];
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
@@ -23,9 +6,6 @@ use Doctrine\DBAL\Driver\AbstractDB2Driver;
|
||||
|
||||
/**
|
||||
* IBM DB2 Driver.
|
||||
*
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class DB2Driver extends AbstractDB2Driver
|
||||
{
|
||||
@@ -34,18 +14,18 @@ class DB2Driver extends AbstractDB2Driver
|
||||
*/
|
||||
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
|
||||
{
|
||||
if ( ! isset($params['protocol'])) {
|
||||
if (! isset($params['protocol'])) {
|
||||
$params['protocol'] = 'TCPIP';
|
||||
}
|
||||
|
||||
if ($params['host'] !== 'localhost' && $params['host'] != '127.0.0.1') {
|
||||
if ($params['host'] !== 'localhost' && $params['host'] !== '127.0.0.1') {
|
||||
// if the host isn't localhost, use extended connection params
|
||||
$params['dbname'] = 'DRIVER={IBM DB2 ODBC DRIVER}' .
|
||||
';DATABASE=' . $params['dbname'] .
|
||||
';HOSTNAME=' . $params['host'] .
|
||||
';PROTOCOL=' . $params['protocol'] .
|
||||
';UID=' . $username .
|
||||
';PWD=' . $password .';';
|
||||
';UID=' . $username .
|
||||
';PWD=' . $password . ';';
|
||||
if (isset($params['port'])) {
|
||||
$params['dbname'] .= 'PORT=' . $params['port'];
|
||||
}
|
||||
|
@@ -1,24 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
class DB2Exception extends \Exception
|
||||
use Exception;
|
||||
|
||||
class DB2Exception extends Exception
|
||||
{
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
@@ -23,11 +6,19 @@ use Doctrine\DBAL\Driver\Statement;
|
||||
use Doctrine\DBAL\Driver\StatementIterator;
|
||||
use Doctrine\DBAL\FetchMode;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use IteratorAggregate;
|
||||
use PDO;
|
||||
use ReflectionClass;
|
||||
use ReflectionObject;
|
||||
use ReflectionProperty;
|
||||
use stdClass;
|
||||
use const CASE_LOWER;
|
||||
use const DB2_BINARY;
|
||||
use const DB2_CHAR;
|
||||
use const DB2_LONG;
|
||||
use const DB2_PARAM_FILE;
|
||||
use const DB2_PARAM_IN;
|
||||
use function array_change_key_case;
|
||||
use function call_user_func_array;
|
||||
use function db2_bind_param;
|
||||
use function db2_execute;
|
||||
use function db2_fetch_array;
|
||||
@@ -39,41 +30,46 @@ use function db2_num_fields;
|
||||
use function db2_num_rows;
|
||||
use function db2_stmt_error;
|
||||
use function db2_stmt_errormsg;
|
||||
use function error_get_last;
|
||||
use function fclose;
|
||||
use function func_get_args;
|
||||
use function func_num_args;
|
||||
use function fwrite;
|
||||
use function gettype;
|
||||
use function is_object;
|
||||
use function is_resource;
|
||||
use function is_string;
|
||||
use function ksort;
|
||||
use function sprintf;
|
||||
use function stream_copy_to_stream;
|
||||
use function stream_get_meta_data;
|
||||
use function strtolower;
|
||||
use function tmpfile;
|
||||
|
||||
class DB2Statement implements \IteratorAggregate, Statement
|
||||
class DB2Statement implements IteratorAggregate, Statement
|
||||
{
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
private $_stmt;
|
||||
/** @var resource */
|
||||
private $stmt;
|
||||
|
||||
/** @var mixed[] */
|
||||
private $bindParam = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* Map of LOB parameter positions to the tuples containing reference to the variable bound to the driver statement
|
||||
* and the temporary file handle bound to the underlying statement
|
||||
*
|
||||
* @var mixed[][]
|
||||
*/
|
||||
private $_bindParam = [];
|
||||
private $lobs = [];
|
||||
|
||||
/**
|
||||
* @var string Name of the default class to instantiate when fetching class instances.
|
||||
*/
|
||||
/** @var string Name of the default class to instantiate when fetching class instances. */
|
||||
private $defaultFetchClass = '\stdClass';
|
||||
|
||||
/**
|
||||
* @var mixed[] Constructor arguments for the default class to instantiate when fetching class instances.
|
||||
*/
|
||||
/** @var mixed[] Constructor arguments for the default class to instantiate when fetching class instances. */
|
||||
private $defaultFetchClassCtorArgs = [];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $_defaultFetchMode = FetchMode::MIXED;
|
||||
/** @var int */
|
||||
private $defaultFetchMode = FetchMode::MIXED;
|
||||
|
||||
/**
|
||||
* Indicates whether the statement is in the state when fetching results is possible
|
||||
@@ -82,22 +78,12 @@ class DB2Statement implements \IteratorAggregate, Statement
|
||||
*/
|
||||
private $result = false;
|
||||
|
||||
/**
|
||||
* DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static private $_typeMap = [
|
||||
ParameterType::INTEGER => DB2_LONG,
|
||||
ParameterType::STRING => DB2_CHAR,
|
||||
];
|
||||
|
||||
/**
|
||||
* @param resource $stmt
|
||||
*/
|
||||
public function __construct($stmt)
|
||||
{
|
||||
$this->_stmt = $stmt;
|
||||
$this->stmt = $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,33 +99,60 @@ class DB2Statement implements \IteratorAggregate, Statement
|
||||
*/
|
||||
public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null)
|
||||
{
|
||||
$this->_bindParam[$column] =& $variable;
|
||||
switch ($type) {
|
||||
case ParameterType::INTEGER:
|
||||
$this->bind($column, $variable, DB2_PARAM_IN, DB2_LONG);
|
||||
break;
|
||||
|
||||
if ($type && isset(self::$_typeMap[$type])) {
|
||||
$type = self::$_typeMap[$type];
|
||||
} else {
|
||||
$type = DB2_CHAR;
|
||||
}
|
||||
case ParameterType::LARGE_OBJECT:
|
||||
if (isset($this->lobs[$column])) {
|
||||
[, $handle] = $this->lobs[$column];
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
if (!db2_bind_param($this->_stmt, $column, "variable", DB2_PARAM_IN, $type)) {
|
||||
throw new DB2Exception(db2_stmt_errormsg());
|
||||
$handle = $this->createTemporaryFile();
|
||||
$path = stream_get_meta_data($handle)['uri'];
|
||||
|
||||
$this->bind($column, $path, DB2_PARAM_FILE, DB2_BINARY);
|
||||
|
||||
$this->lobs[$column] = [&$variable, $handle];
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->bind($column, $variable, DB2_PARAM_IN, DB2_CHAR);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|string $parameter Parameter position or name
|
||||
* @param mixed $variable
|
||||
*
|
||||
* @throws DB2Exception
|
||||
*/
|
||||
private function bind($parameter, &$variable, int $parameterType, int $dataType) : void
|
||||
{
|
||||
$this->bindParam[$parameter] =& $variable;
|
||||
|
||||
if (! db2_bind_param($this->stmt, $parameter, 'variable', $parameterType, $dataType)) {
|
||||
throw new DB2Exception(db2_stmt_errormsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function closeCursor()
|
||||
{
|
||||
if ( ! $this->_stmt) {
|
||||
if (! $this->stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_bindParam = [];
|
||||
$this->bindParam = [];
|
||||
|
||||
if (!db2_free_result($this->_stmt)) {
|
||||
if (! db2_free_result($this->stmt)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -153,11 +166,11 @@ class DB2Statement implements \IteratorAggregate, Statement
|
||||
*/
|
||||
public function columnCount()
|
||||
{
|
||||
if ( ! $this->_stmt) {
|
||||
if (! $this->stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return db2_num_fields($this->_stmt);
|
||||
return db2_num_fields($this->stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,21 +197,37 @@ class DB2Statement implements \IteratorAggregate, Statement
|
||||
*/
|
||||
public function execute($params = null)
|
||||
{
|
||||
if ( ! $this->_stmt) {
|
||||
if (! $this->stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($params === null) {
|
||||
ksort($this->_bindParam);
|
||||
ksort($this->bindParam);
|
||||
|
||||
$params = [];
|
||||
|
||||
foreach ($this->_bindParam as $column => $value) {
|
||||
foreach ($this->bindParam as $column => $value) {
|
||||
$params[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$retval = db2_execute($this->_stmt, $params);
|
||||
foreach ($this->lobs as [$source, $target]) {
|
||||
if (is_resource($source)) {
|
||||
$this->copyStreamToStream($source, $target);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->writeStringToStream($source, $target);
|
||||
}
|
||||
|
||||
$retval = db2_execute($this->stmt, $params);
|
||||
|
||||
foreach ($this->lobs as [, $handle]) {
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
$this->lobs = [];
|
||||
|
||||
if ($retval === false) {
|
||||
throw new DB2Exception(db2_stmt_errormsg());
|
||||
@@ -214,7 +243,7 @@ class DB2Statement implements \IteratorAggregate, Statement
|
||||
*/
|
||||
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
|
||||
{
|
||||
$this->_defaultFetchMode = $fetchMode;
|
||||
$this->defaultFetchMode = $fetchMode;
|
||||
$this->defaultFetchClass = $arg2 ?: $this->defaultFetchClass;
|
||||
$this->defaultFetchClassCtorArgs = $arg3 ? (array) $arg3 : $this->defaultFetchClassCtorArgs;
|
||||
|
||||
@@ -232,24 +261,24 @@ class DB2Statement implements \IteratorAggregate, Statement
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
// do not try fetching from the statement if it's not expected to contain result
|
||||
// in order to prevent exceptional situation
|
||||
if (!$this->result) {
|
||||
if (! $this->result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$fetchMode = $fetchMode ?: $this->_defaultFetchMode;
|
||||
$fetchMode = $fetchMode ?: $this->defaultFetchMode;
|
||||
switch ($fetchMode) {
|
||||
case FetchMode::COLUMN:
|
||||
return $this->fetchColumn();
|
||||
|
||||
case FetchMode::MIXED:
|
||||
return db2_fetch_both($this->_stmt);
|
||||
return db2_fetch_both($this->stmt);
|
||||
|
||||
case FetchMode::ASSOCIATIVE:
|
||||
return db2_fetch_assoc($this->_stmt);
|
||||
return db2_fetch_assoc($this->stmt);
|
||||
|
||||
case FetchMode::CUSTOM_OBJECT:
|
||||
$className = $this->defaultFetchClass;
|
||||
@@ -261,19 +290,19 @@ class DB2Statement implements \IteratorAggregate, Statement
|
||||
$ctorArgs = $args[2] ?? [];
|
||||
}
|
||||
|
||||
$result = db2_fetch_object($this->_stmt);
|
||||
$result = db2_fetch_object($this->stmt);
|
||||
|
||||
if ($result instanceof \stdClass) {
|
||||
if ($result instanceof stdClass) {
|
||||
$result = $this->castObject($result, $className, $ctorArgs);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
case FetchMode::NUMERIC:
|
||||
return db2_fetch_array($this->_stmt);
|
||||
return db2_fetch_array($this->stmt);
|
||||
|
||||
case FetchMode::STANDARD_OBJECT:
|
||||
return db2_fetch_object($this->_stmt);
|
||||
return db2_fetch_object($this->stmt);
|
||||
|
||||
default:
|
||||
throw new DB2Exception('Given Fetch-Style ' . $fetchMode . ' is not supported.');
|
||||
@@ -314,7 +343,7 @@ class DB2Statement implements \IteratorAggregate, Statement
|
||||
{
|
||||
$row = $this->fetch(FetchMode::NUMERIC);
|
||||
|
||||
if (false === $row) {
|
||||
if ($row === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -326,37 +355,38 @@ class DB2Statement implements \IteratorAggregate, Statement
|
||||
*/
|
||||
public function rowCount()
|
||||
{
|
||||
return (@db2_num_rows($this->_stmt)) ? : 0;
|
||||
return @db2_num_rows($this->stmt) ? : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a stdClass object to the given class name mapping its' properties.
|
||||
*
|
||||
* @param \stdClass $sourceObject Object to cast from.
|
||||
* @param stdClass $sourceObject Object to cast from.
|
||||
* @param string|object $destinationClass Name of the class or class instance to cast to.
|
||||
* @param array $ctorArgs Arguments to use for constructing the destination class instance.
|
||||
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @throws DB2Exception
|
||||
*/
|
||||
private function castObject(\stdClass $sourceObject, $destinationClass, array $ctorArgs = [])
|
||||
private function castObject(stdClass $sourceObject, $destinationClass, array $ctorArgs = [])
|
||||
{
|
||||
if ( ! is_string($destinationClass)) {
|
||||
if ( ! is_object($destinationClass)) {
|
||||
if (! is_string($destinationClass)) {
|
||||
if (! is_object($destinationClass)) {
|
||||
throw new DB2Exception(sprintf(
|
||||
'Destination class has to be of type string or object, %s given.', gettype($destinationClass)
|
||||
'Destination class has to be of type string or object, %s given.',
|
||||
gettype($destinationClass)
|
||||
));
|
||||
}
|
||||
} else {
|
||||
$destinationClass = new \ReflectionClass($destinationClass);
|
||||
$destinationClass = new ReflectionClass($destinationClass);
|
||||
$destinationClass = $destinationClass->newInstanceArgs($ctorArgs);
|
||||
}
|
||||
|
||||
$sourceReflection = new \ReflectionObject($sourceObject);
|
||||
$destinationClassReflection = new \ReflectionObject($destinationClass);
|
||||
/** @var \ReflectionProperty[] $destinationProperties */
|
||||
$destinationProperties = array_change_key_case($destinationClassReflection->getProperties(), \CASE_LOWER);
|
||||
$sourceReflection = new ReflectionObject($sourceObject);
|
||||
$destinationClassReflection = new ReflectionObject($destinationClass);
|
||||
/** @var ReflectionProperty[] $destinationProperties */
|
||||
$destinationProperties = array_change_key_case($destinationClassReflection->getProperties(), CASE_LOWER);
|
||||
|
||||
foreach ($sourceReflection->getProperties() as $sourceProperty) {
|
||||
$sourceProperty->setAccessible(true);
|
||||
@@ -392,4 +422,45 @@ class DB2Statement implements \IteratorAggregate, Statement
|
||||
|
||||
return $destinationClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
*
|
||||
* @throws DB2Exception
|
||||
*/
|
||||
private function createTemporaryFile()
|
||||
{
|
||||
$handle = @tmpfile();
|
||||
|
||||
if ($handle === false) {
|
||||
throw new DB2Exception('Could not create temporary file: ' . error_get_last()['message']);
|
||||
}
|
||||
|
||||
return $handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $source
|
||||
* @param resource $target
|
||||
*
|
||||
* @throws DB2Exception
|
||||
*/
|
||||
private function copyStreamToStream($source, $target) : void
|
||||
{
|
||||
if (@stream_copy_to_stream($source, $target) === false) {
|
||||
throw new DB2Exception('Could not copy source stream to temporary file: ' . error_get_last()['message']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $target
|
||||
*
|
||||
* @throws DB2Exception
|
||||
*/
|
||||
private function writeStringToStream(string $string, $target) : void
|
||||
{
|
||||
if (@fwrite($target, $string) === false) {
|
||||
throw new DB2Exception('Could not write string to temporary file: ' . error_get_last()['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,30 +1,10 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
|
||||
|
||||
/**
|
||||
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
|
||||
*/
|
||||
class Driver extends AbstractMySQLDriver
|
||||
{
|
||||
/**
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli;
|
||||
|
||||
@@ -23,6 +6,13 @@ use Doctrine\DBAL\Driver\Connection;
|
||||
use Doctrine\DBAL\Driver\PingableConnection;
|
||||
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use mysqli;
|
||||
use const MYSQLI_INIT_COMMAND;
|
||||
use const MYSQLI_OPT_CONNECT_TIMEOUT;
|
||||
use const MYSQLI_OPT_LOCAL_INFILE;
|
||||
use const MYSQLI_READ_DEFAULT_FILE;
|
||||
use const MYSQLI_READ_DEFAULT_GROUP;
|
||||
use const MYSQLI_SERVER_PUBLIC_KEY;
|
||||
use function defined;
|
||||
use function floor;
|
||||
use function func_get_args;
|
||||
@@ -37,36 +27,30 @@ use function set_error_handler;
|
||||
use function sprintf;
|
||||
use function stripos;
|
||||
|
||||
/**
|
||||
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
|
||||
* @author Till Klampaeckel <till@php.net>
|
||||
*/
|
||||
class MysqliConnection implements Connection, PingableConnection, ServerInfoAwareConnection
|
||||
{
|
||||
/**
|
||||
* Name of the option to set connection flags
|
||||
*/
|
||||
const OPTION_FLAGS = 'flags';
|
||||
public const OPTION_FLAGS = 'flags';
|
||||
|
||||
/** @var mysqli */
|
||||
private $conn;
|
||||
|
||||
/**
|
||||
* @var \mysqli
|
||||
*/
|
||||
private $_conn;
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param array $driverOptions
|
||||
* @param mixed[] $params
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param mixed[] $driverOptions
|
||||
*
|
||||
* @throws \Doctrine\DBAL\Driver\Mysqli\MysqliException
|
||||
* @throws MysqliException
|
||||
*/
|
||||
public function __construct(array $params, $username, $password, array $driverOptions = [])
|
||||
{
|
||||
$port = $params['port'] ?? ini_get('mysqli.default_port');
|
||||
|
||||
// Fallback to default MySQL port if not given.
|
||||
if ( ! $port) {
|
||||
if (! $port) {
|
||||
$port = 3306;
|
||||
}
|
||||
|
||||
@@ -75,23 +59,26 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
|
||||
$flags = $driverOptions[static::OPTION_FLAGS] ?? null;
|
||||
|
||||
$this->_conn = mysqli_init();
|
||||
$this->conn = mysqli_init();
|
||||
|
||||
$this->setSecureConnection($params);
|
||||
$this->setDriverOptions($driverOptions);
|
||||
|
||||
set_error_handler(function () {});
|
||||
set_error_handler(static function () {
|
||||
});
|
||||
try {
|
||||
if ( ! $this->_conn->real_connect($params['host'], $username, $password, $dbname, $port, $socket, $flags)) {
|
||||
throw new MysqliException($this->_conn->connect_error, $this->_conn->sqlstate ?? 'HY000', $this->_conn->connect_errno);
|
||||
if (! $this->conn->real_connect($params['host'], $username, $password, $dbname, $port, $socket, $flags)) {
|
||||
throw new MysqliException($this->conn->connect_error, $this->conn->sqlstate ?? 'HY000', $this->conn->connect_errno);
|
||||
}
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
if (isset($params['charset'])) {
|
||||
$this->_conn->set_charset($params['charset']);
|
||||
if (! isset($params['charset'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->conn->set_charset($params['charset']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,11 +86,11 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*
|
||||
* Could be used if part of your application is not using DBAL.
|
||||
*
|
||||
* @return \mysqli
|
||||
* @return mysqli
|
||||
*/
|
||||
public function getWrappedResourceHandle()
|
||||
{
|
||||
return $this->_conn;
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,18 +98,19 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*
|
||||
* The server version detection includes a special case for MariaDB
|
||||
* to support '5.5.5-' prefixed versions introduced in Maria 10+
|
||||
*
|
||||
* @link https://jira.mariadb.org/browse/MDEV-4088
|
||||
*/
|
||||
public function getServerVersion()
|
||||
{
|
||||
$serverInfos = $this->_conn->get_server_info();
|
||||
if (false !== stripos($serverInfos, 'mariadb')) {
|
||||
$serverInfos = $this->conn->get_server_info();
|
||||
if (stripos($serverInfos, 'mariadb') !== false) {
|
||||
return $serverInfos;
|
||||
}
|
||||
|
||||
$majorVersion = floor($this->_conn->server_version / 10000);
|
||||
$minorVersion = floor(($this->_conn->server_version - $majorVersion * 10000) / 100);
|
||||
$patchVersion = floor($this->_conn->server_version - $majorVersion * 10000 - $minorVersion * 100);
|
||||
$majorVersion = floor($this->conn->server_version / 10000);
|
||||
$minorVersion = floor(($this->conn->server_version - $majorVersion * 10000) / 100);
|
||||
$patchVersion = floor($this->conn->server_version - $majorVersion * 10000 - $minorVersion * 100);
|
||||
|
||||
return $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
|
||||
}
|
||||
@@ -140,7 +128,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*/
|
||||
public function prepare($prepareString)
|
||||
{
|
||||
return new MysqliStatement($this->_conn, $prepareString);
|
||||
return new MysqliStatement($this->conn, $prepareString);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +137,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
public function query()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$sql = $args[0];
|
||||
$sql = $args[0];
|
||||
$stmt = $this->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
@@ -161,7 +149,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*/
|
||||
public function quote($input, $type = ParameterType::STRING)
|
||||
{
|
||||
return "'". $this->_conn->escape_string($input) ."'";
|
||||
return "'" . $this->conn->escape_string($input) . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,11 +157,11 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*/
|
||||
public function exec($statement)
|
||||
{
|
||||
if (false === $this->_conn->query($statement)) {
|
||||
throw new MysqliException($this->_conn->error, $this->_conn->sqlstate, $this->_conn->errno);
|
||||
if ($this->conn->query($statement) === false) {
|
||||
throw new MysqliException($this->conn->error, $this->conn->sqlstate, $this->conn->errno);
|
||||
}
|
||||
|
||||
return $this->_conn->affected_rows;
|
||||
return $this->conn->affected_rows;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +169,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*/
|
||||
public function lastInsertId($name = null)
|
||||
{
|
||||
return $this->_conn->insert_id;
|
||||
return $this->conn->insert_id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +177,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
$this->_conn->query('START TRANSACTION');
|
||||
$this->conn->query('START TRANSACTION');
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -199,7 +187,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
return $this->_conn->commit();
|
||||
return $this->conn->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +195,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*/
|
||||
public function rollBack()
|
||||
{
|
||||
return $this->_conn->rollback();
|
||||
return $this->conn->rollback();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +203,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*/
|
||||
public function errorCode()
|
||||
{
|
||||
return $this->_conn->errno;
|
||||
return $this->conn->errno;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,13 +211,13 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*/
|
||||
public function errorInfo()
|
||||
{
|
||||
return $this->_conn->error;
|
||||
return $this->conn->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the driver options to the connection.
|
||||
*
|
||||
* @param array $driverOptions
|
||||
* @param mixed[] $driverOptions
|
||||
*
|
||||
* @throws MysqliException When one of of the options is not supported.
|
||||
* @throws MysqliException When applying doesn't work - e.g. due to incorrect value.
|
||||
@@ -237,42 +225,41 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
private function setDriverOptions(array $driverOptions = [])
|
||||
{
|
||||
$supportedDriverOptions = [
|
||||
\MYSQLI_OPT_CONNECT_TIMEOUT,
|
||||
\MYSQLI_OPT_LOCAL_INFILE,
|
||||
\MYSQLI_INIT_COMMAND,
|
||||
\MYSQLI_READ_DEFAULT_FILE,
|
||||
\MYSQLI_READ_DEFAULT_GROUP,
|
||||
MYSQLI_OPT_CONNECT_TIMEOUT,
|
||||
MYSQLI_OPT_LOCAL_INFILE,
|
||||
MYSQLI_INIT_COMMAND,
|
||||
MYSQLI_READ_DEFAULT_FILE,
|
||||
MYSQLI_READ_DEFAULT_GROUP,
|
||||
];
|
||||
|
||||
if (defined('MYSQLI_SERVER_PUBLIC_KEY')) {
|
||||
$supportedDriverOptions[] = \MYSQLI_SERVER_PUBLIC_KEY;
|
||||
$supportedDriverOptions[] = MYSQLI_SERVER_PUBLIC_KEY;
|
||||
}
|
||||
|
||||
$exceptionMsg = "%s option '%s' with value '%s'";
|
||||
|
||||
foreach ($driverOptions as $option => $value) {
|
||||
|
||||
if ($option === static::OPTION_FLAGS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!in_array($option, $supportedDriverOptions, true)) {
|
||||
if (! in_array($option, $supportedDriverOptions, true)) {
|
||||
throw new MysqliException(
|
||||
sprintf($exceptionMsg, 'Unsupported', $option, $value)
|
||||
);
|
||||
}
|
||||
|
||||
if (@mysqli_options($this->_conn, $option, $value)) {
|
||||
if (@mysqli_options($this->conn, $option, $value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$msg = sprintf($exceptionMsg, 'Failed to set', $option, $value);
|
||||
$msg .= sprintf(', error: %s (%d)', mysqli_error($this->_conn), mysqli_errno($this->_conn));
|
||||
$msg .= sprintf(', error: %s (%d)', mysqli_error($this->conn), mysqli_errno($this->conn));
|
||||
|
||||
throw new MysqliException(
|
||||
$msg,
|
||||
$this->_conn->sqlstate,
|
||||
$this->_conn->errno
|
||||
$this->conn->sqlstate,
|
||||
$this->conn->errno
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -284,13 +271,14 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
*/
|
||||
public function ping()
|
||||
{
|
||||
return $this->_conn->ping();
|
||||
return $this->conn->ping();
|
||||
}
|
||||
|
||||
/**
|
||||
* Establish a secure connection
|
||||
*
|
||||
* @param array $params
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @throws MysqliException
|
||||
*/
|
||||
private function setSecureConnection(array $params)
|
||||
@@ -304,7 +292,7 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_conn->ssl_set(
|
||||
$this->conn->ssl_set(
|
||||
$params['ssl_key'] ?? null,
|
||||
$params['ssl_cert'] ?? null,
|
||||
$params['ssl_ca'] ?? null,
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli;
|
||||
|
||||
@@ -23,9 +6,6 @@ use Doctrine\DBAL\Driver\AbstractDriverException;
|
||||
|
||||
/**
|
||||
* Exception thrown in case the mysqli driver errors.
|
||||
*
|
||||
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
*/
|
||||
class MysqliException extends AbstractDriverException
|
||||
{
|
||||
|
@@ -1,93 +1,65 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli;
|
||||
|
||||
use Doctrine\DBAL\Driver\Statement;
|
||||
use Doctrine\DBAL\Driver\StatementIterator;
|
||||
use Doctrine\DBAL\Exception\InvalidArgumentException;
|
||||
use Doctrine\DBAL\FetchMode;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use IteratorAggregate;
|
||||
use mysqli;
|
||||
use mysqli_stmt;
|
||||
use PDO;
|
||||
use stdClass;
|
||||
use function array_combine;
|
||||
use function array_fill;
|
||||
use function call_user_func_array;
|
||||
use function count;
|
||||
use function feof;
|
||||
use function fread;
|
||||
use function get_resource_type;
|
||||
use function is_resource;
|
||||
use function sprintf;
|
||||
use function str_repeat;
|
||||
|
||||
/**
|
||||
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
|
||||
*/
|
||||
class MysqliStatement implements \IteratorAggregate, Statement
|
||||
class MysqliStatement implements IteratorAggregate, Statement
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var string[] */
|
||||
protected static $_paramTypeMap = [
|
||||
ParameterType::STRING => 's',
|
||||
ParameterType::BINARY => 's',
|
||||
ParameterType::BOOLEAN => 'i',
|
||||
ParameterType::NULL => 's',
|
||||
ParameterType::INTEGER => 'i',
|
||||
|
||||
// TODO Support LOB bigger then max package size
|
||||
ParameterType::LARGE_OBJECT => 's',
|
||||
ParameterType::LARGE_OBJECT => 'b',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var \mysqli
|
||||
*/
|
||||
/** @var mysqli */
|
||||
protected $_conn;
|
||||
|
||||
/**
|
||||
* @var \mysqli_stmt
|
||||
*/
|
||||
/** @var mysqli_stmt */
|
||||
protected $_stmt;
|
||||
|
||||
/**
|
||||
* @var null|boolean|array
|
||||
*/
|
||||
/** @var string[]|bool|null */
|
||||
protected $_columnNames;
|
||||
|
||||
/**
|
||||
* @var null|array
|
||||
*/
|
||||
/** @var mixed[]|null */
|
||||
protected $_rowBindedValues;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var mixed[] */
|
||||
protected $_bindedValues;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $types;
|
||||
|
||||
/**
|
||||
* Contains ref values for bindValue().
|
||||
*
|
||||
* @var array
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $_values = [];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
protected $_defaultFetchMode = FetchMode::MIXED;
|
||||
|
||||
/**
|
||||
@@ -98,24 +70,25 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
private $result = false;
|
||||
|
||||
/**
|
||||
* @param \mysqli $conn
|
||||
* @param string $prepareString
|
||||
* @param string $prepareString
|
||||
*
|
||||
* @throws \Doctrine\DBAL\Driver\Mysqli\MysqliException
|
||||
* @throws MysqliException
|
||||
*/
|
||||
public function __construct(\mysqli $conn, $prepareString)
|
||||
public function __construct(mysqli $conn, $prepareString)
|
||||
{
|
||||
$this->_conn = $conn;
|
||||
$this->_stmt = $conn->prepare($prepareString);
|
||||
if (false === $this->_stmt) {
|
||||
if ($this->_stmt === false) {
|
||||
throw new MysqliException($this->_conn->error, $this->_conn->sqlstate, $this->_conn->errno);
|
||||
}
|
||||
|
||||
$paramCount = $this->_stmt->param_count;
|
||||
if (0 < $paramCount) {
|
||||
$this->types = str_repeat('s', $paramCount);
|
||||
$this->_bindedValues = array_fill(1, $paramCount, null);
|
||||
if (0 >= $paramCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->types = str_repeat('s', $paramCount);
|
||||
$this->_bindedValues = array_fill(1, $paramCount, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,18 +96,18 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
*/
|
||||
public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null)
|
||||
{
|
||||
if (null === $type) {
|
||||
if ($type === null) {
|
||||
$type = 's';
|
||||
} else {
|
||||
if (isset(self::$_paramTypeMap[$type])) {
|
||||
$type = self::$_paramTypeMap[$type];
|
||||
} else {
|
||||
throw new MysqliException("Unknown type: '{$type}'");
|
||||
if (! isset(self::$_paramTypeMap[$type])) {
|
||||
throw new MysqliException(sprintf("Unknown type: '%s'", $type));
|
||||
}
|
||||
|
||||
$type = self::$_paramTypeMap[$type];
|
||||
}
|
||||
|
||||
$this->_bindedValues[$column] =& $variable;
|
||||
$this->types[$column - 1] = $type;
|
||||
$this->types[$column - 1] = $type;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -144,19 +117,19 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
*/
|
||||
public function bindValue($param, $value, $type = ParameterType::STRING)
|
||||
{
|
||||
if (null === $type) {
|
||||
if ($type === null) {
|
||||
$type = 's';
|
||||
} else {
|
||||
if (isset(self::$_paramTypeMap[$type])) {
|
||||
$type = self::$_paramTypeMap[$type];
|
||||
} else {
|
||||
throw new MysqliException("Unknown type: '{$type}'");
|
||||
if (! isset(self::$_paramTypeMap[$type])) {
|
||||
throw new MysqliException(sprintf("Unknown type: '%s'", $type));
|
||||
}
|
||||
|
||||
$type = self::$_paramTypeMap[$type];
|
||||
}
|
||||
|
||||
$this->_values[$param] = $value;
|
||||
$this->_values[$param] = $value;
|
||||
$this->_bindedValues[$param] =& $this->_values[$param];
|
||||
$this->types[$param - 1] = $type;
|
||||
$this->types[$param - 1] = $type;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -166,25 +139,27 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
*/
|
||||
public function execute($params = null)
|
||||
{
|
||||
if (null !== $this->_bindedValues) {
|
||||
if (null !== $params) {
|
||||
if ( ! $this->_bindValues($params)) {
|
||||
if ($this->_bindedValues !== null) {
|
||||
if ($params !== null) {
|
||||
if (! $this->_bindValues($params)) {
|
||||
throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
|
||||
}
|
||||
} else {
|
||||
if (!call_user_func_array([$this->_stmt, 'bind_param'], [$this->types] + $this->_bindedValues)) {
|
||||
[$types, $values, $streams] = $this->separateBoundValues();
|
||||
if (! $this->_stmt->bind_param($types, ...$values)) {
|
||||
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
|
||||
}
|
||||
$this->sendLongData($streams);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $this->_stmt->execute()) {
|
||||
if (! $this->_stmt->execute()) {
|
||||
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
|
||||
}
|
||||
|
||||
if (null === $this->_columnNames) {
|
||||
if ($this->_columnNames === null) {
|
||||
$meta = $this->_stmt->result_metadata();
|
||||
if (false !== $meta) {
|
||||
if ($meta !== false) {
|
||||
$columnNames = [];
|
||||
foreach ($meta->fetch_fields() as $col) {
|
||||
$columnNames[] = $col->name;
|
||||
@@ -197,7 +172,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
}
|
||||
}
|
||||
|
||||
if (false !== $this->_columnNames) {
|
||||
if ($this->_columnNames !== false) {
|
||||
// Store result of every execution which has it. Otherwise it will be impossible
|
||||
// to execute a new statement in case if the previous one has non-fetched rows
|
||||
// @link http://dev.mysql.com/doc/refman/5.7/en/commands-out-of-sync.html
|
||||
@@ -221,7 +196,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
$refs[$key] =& $value;
|
||||
}
|
||||
|
||||
if (!call_user_func_array([$this->_stmt, 'bind_result'], $refs)) {
|
||||
if (! $this->_stmt->bind_result(...$refs)) {
|
||||
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
|
||||
}
|
||||
}
|
||||
@@ -231,24 +206,80 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split $this->_bindedValues into those values that need to be sent using mysqli::send_long_data()
|
||||
* and those that can be bound the usual way.
|
||||
*
|
||||
* @return array<int, array<int|string, mixed>|string>
|
||||
*/
|
||||
private function separateBoundValues()
|
||||
{
|
||||
$streams = $values = [];
|
||||
$types = $this->types;
|
||||
|
||||
foreach ($this->_bindedValues as $parameter => $value) {
|
||||
if (! isset($types[$parameter - 1])) {
|
||||
$types[$parameter - 1] = static::$_paramTypeMap[ParameterType::STRING];
|
||||
}
|
||||
|
||||
if ($types[$parameter - 1] === static::$_paramTypeMap[ParameterType::LARGE_OBJECT]) {
|
||||
if (is_resource($value)) {
|
||||
if (get_resource_type($value) !== 'stream') {
|
||||
throw new InvalidArgumentException('Resources passed with the LARGE_OBJECT parameter type must be stream resources.');
|
||||
}
|
||||
$streams[$parameter] = $value;
|
||||
$values[$parameter] = null;
|
||||
continue;
|
||||
} else {
|
||||
$types[$parameter - 1] = static::$_paramTypeMap[ParameterType::STRING];
|
||||
}
|
||||
}
|
||||
|
||||
$values[$parameter] = $value;
|
||||
}
|
||||
|
||||
return [$types, $values, $streams];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle $this->_longData after regular query parameters have been bound
|
||||
*
|
||||
* @throws MysqliException
|
||||
*/
|
||||
private function sendLongData($streams)
|
||||
{
|
||||
foreach ($streams as $paramNr => $stream) {
|
||||
while (! feof($stream)) {
|
||||
$chunk = fread($stream, 8192);
|
||||
|
||||
if ($chunk === false) {
|
||||
throw new MysqliException("Failed reading the stream resource for parameter offset ${paramNr}.");
|
||||
}
|
||||
|
||||
if (! $this->_stmt->send_long_data($paramNr - 1, $chunk)) {
|
||||
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds a array of values to bound parameters.
|
||||
*
|
||||
* @param array $values
|
||||
* @param mixed[] $values
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function _bindValues($values)
|
||||
{
|
||||
$params = [];
|
||||
$types = str_repeat('s', count($values));
|
||||
$params[0] = $types;
|
||||
$types = str_repeat('s', count($values));
|
||||
|
||||
foreach ($values as &$v) {
|
||||
$params[] =& $v;
|
||||
}
|
||||
|
||||
return call_user_func_array([$this->_stmt, 'bind_param'], $params);
|
||||
return $this->_stmt->bind_param($types, ...$params);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,7 +289,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
{
|
||||
$ret = $this->_stmt->fetch();
|
||||
|
||||
if (true === $ret) {
|
||||
if ($ret === true) {
|
||||
$values = [];
|
||||
foreach ($this->_rowBindedValues as $v) {
|
||||
$values[] = $v;
|
||||
@@ -273,11 +304,11 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
// do not try fetching from the statement if it's not expected to contain result
|
||||
// in order to prevent exceptional situation
|
||||
if (!$this->result) {
|
||||
if (! $this->result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -288,11 +319,11 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
}
|
||||
|
||||
$values = $this->_fetch();
|
||||
if (null === $values) {
|
||||
if ($values === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false === $values) {
|
||||
if ($values === false) {
|
||||
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
|
||||
}
|
||||
|
||||
@@ -304,14 +335,14 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
return array_combine($this->_columnNames, $values);
|
||||
|
||||
case FetchMode::MIXED:
|
||||
$ret = array_combine($this->_columnNames, $values);
|
||||
$ret = array_combine($this->_columnNames, $values);
|
||||
$ret += $values;
|
||||
|
||||
return $ret;
|
||||
|
||||
case FetchMode::STANDARD_OBJECT:
|
||||
$assoc = array_combine($this->_columnNames, $values);
|
||||
$ret = new \stdClass();
|
||||
$ret = new stdClass();
|
||||
|
||||
foreach ($assoc as $column => $value) {
|
||||
$ret->$column = $value;
|
||||
@@ -320,7 +351,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
return $ret;
|
||||
|
||||
default:
|
||||
throw new MysqliException("Unknown fetch type '{$fetchMode}'");
|
||||
throw new MysqliException(sprintf("Unknown fetch type '%s'", $fetchMode));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +384,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
{
|
||||
$row = $this->fetch(FetchMode::NUMERIC);
|
||||
|
||||
if (false === $row) {
|
||||
if ($row === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -392,7 +423,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
|
||||
*/
|
||||
public function rowCount()
|
||||
{
|
||||
if (false === $this->_columnNames) {
|
||||
if ($this->_columnNames === false) {
|
||||
return $this->_stmt->affected_rows;
|
||||
}
|
||||
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\OCI8;
|
||||
|
||||
@@ -25,9 +8,6 @@ use const OCI_DEFAULT;
|
||||
|
||||
/**
|
||||
* A Doctrine DBAL driver for the Oracle OCI8 PHP extensions.
|
||||
*
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Driver extends AbstractOracleDriver
|
||||
{
|
||||
@@ -53,7 +33,7 @@ class Driver extends AbstractOracleDriver
|
||||
/**
|
||||
* Constructs the Oracle DSN.
|
||||
*
|
||||
* @param array $params
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return string The DSN.
|
||||
*/
|
||||
|
@@ -1,27 +1,11 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\OCI8;
|
||||
|
||||
use Doctrine\DBAL\Driver\Connection;
|
||||
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use UnexpectedValueException;
|
||||
use const OCI_COMMIT_ON_SUCCESS;
|
||||
use const OCI_DEFAULT;
|
||||
use const OCI_NO_AUTO_COMMIT;
|
||||
@@ -43,19 +27,13 @@ use function str_replace;
|
||||
|
||||
/**
|
||||
* OCI8 implementation of the Connection interface.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
class OCI8Connection implements Connection, ServerInfoAwareConnection
|
||||
{
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
/** @var resource */
|
||||
protected $dbh;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
protected $executeMode = OCI_COMMIT_ON_SUCCESS;
|
||||
|
||||
/**
|
||||
@@ -72,7 +50,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function __construct($username, $password, $db, $charset = null, $sessionMode = OCI_DEFAULT, $persistent = false)
|
||||
{
|
||||
if (!defined('OCI_NO_AUTO_COMMIT')) {
|
||||
if (! defined('OCI_NO_AUTO_COMMIT')) {
|
||||
define('OCI_NO_AUTO_COMMIT', 0);
|
||||
}
|
||||
|
||||
@@ -80,7 +58,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
|
||||
? @oci_pconnect($username, $password, $db, $charset, $sessionMode)
|
||||
: @oci_connect($username, $password, $db, $charset, $sessionMode);
|
||||
|
||||
if ( ! $this->dbh) {
|
||||
if (! $this->dbh) {
|
||||
throw OCI8Exception::fromErrorInfo(oci_error());
|
||||
}
|
||||
}
|
||||
@@ -88,13 +66,13 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws \UnexpectedValueException if the version string returned by the database server
|
||||
* does not contain a parsable version number.
|
||||
* @throws UnexpectedValueException If the version string returned by the database server
|
||||
* does not contain a parsable version number.
|
||||
*/
|
||||
public function getServerVersion()
|
||||
{
|
||||
if ( ! preg_match('/\s+(\d+\.\d+\.\d+\.\d+\.\d+)\s+/', oci_server_version($this->dbh), $version)) {
|
||||
throw new \UnexpectedValueException(
|
||||
if (! preg_match('/\s+(\d+\.\d+\.\d+\.\d+\.\d+)\s+/', oci_server_version($this->dbh), $version)) {
|
||||
throw new UnexpectedValueException(
|
||||
sprintf(
|
||||
'Unexpected database version string "%s". Cannot parse an appropriate version number from it. ' .
|
||||
'Please report this database version string to the Doctrine team.',
|
||||
@@ -128,7 +106,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
|
||||
public function query()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$sql = $args[0];
|
||||
$sql = $args[0];
|
||||
//$fetchMode = $args[1];
|
||||
$stmt = $this->prepare($sql);
|
||||
$stmt->execute();
|
||||
@@ -174,7 +152,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
|
||||
$result = $stmt->fetchColumn();
|
||||
|
||||
if ($result === false) {
|
||||
throw new OCI8Exception("lastInsertId failed: Query was executed but no result was returned.");
|
||||
throw new OCI8Exception('lastInsertId failed: Query was executed but no result was returned.');
|
||||
}
|
||||
|
||||
return (int) $result;
|
||||
@@ -205,7 +183,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
if (!oci_commit($this->dbh)) {
|
||||
if (! oci_commit($this->dbh)) {
|
||||
throw OCI8Exception::fromErrorInfo($this->errorInfo());
|
||||
}
|
||||
$this->executeMode = OCI_COMMIT_ON_SUCCESS;
|
||||
@@ -218,7 +196,7 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function rollBack()
|
||||
{
|
||||
if (!oci_rollback($this->dbh)) {
|
||||
if (! oci_rollback($this->dbh)) {
|
||||
throw OCI8Exception::fromErrorInfo($this->errorInfo());
|
||||
}
|
||||
$this->executeMode = OCI_COMMIT_ON_SUCCESS;
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\OCI8;
|
||||
|
||||
@@ -24,7 +7,7 @@ use Doctrine\DBAL\Driver\AbstractDriverException;
|
||||
class OCI8Exception extends AbstractDriverException
|
||||
{
|
||||
/**
|
||||
* @param array $error
|
||||
* @param mixed[] $error
|
||||
*
|
||||
* @return \Doctrine\DBAL\Driver\OCI8\OCI8Exception
|
||||
*/
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\OCI8;
|
||||
|
||||
@@ -23,7 +6,9 @@ use Doctrine\DBAL\Driver\Statement;
|
||||
use Doctrine\DBAL\Driver\StatementIterator;
|
||||
use Doctrine\DBAL\FetchMode;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use InvalidArgumentException;
|
||||
use IteratorAggregate;
|
||||
use PDO;
|
||||
use const OCI_ASSOC;
|
||||
use const OCI_B_BIN;
|
||||
use const OCI_B_BLOB;
|
||||
@@ -59,35 +44,22 @@ use function substr;
|
||||
|
||||
/**
|
||||
* The OCI8 implementation of the Statement interface.
|
||||
*
|
||||
* @since 2.0
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
class OCI8Statement implements IteratorAggregate, Statement
|
||||
{
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
/** @var resource */
|
||||
protected $_dbh;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
/** @var resource */
|
||||
protected $_sth;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Driver\OCI8\OCI8Connection
|
||||
*/
|
||||
/** @var OCI8Connection */
|
||||
protected $_conn;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected static $_PARAM = ':param';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var int[] */
|
||||
protected static $fetchModeMap = [
|
||||
FetchMode::MIXED => OCI_BOTH,
|
||||
FetchMode::ASSOCIATIVE => OCI_ASSOC,
|
||||
@@ -95,14 +67,10 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
FetchMode::COLUMN => OCI_NUM,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
protected $_defaultFetchMode = FetchMode::MIXED;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var string[] */
|
||||
protected $_paramMap = [];
|
||||
|
||||
/**
|
||||
@@ -110,7 +78,7 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
*
|
||||
* This is a new requirement for PHP7's oci8 extension that prevents bound values from being garbage collected.
|
||||
*
|
||||
* @var array
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $boundValues = [];
|
||||
|
||||
@@ -124,17 +92,16 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
/**
|
||||
* Creates a new OCI8Statement that uses the given connection handle and SQL statement.
|
||||
*
|
||||
* @param resource $dbh The connection handle.
|
||||
* @param string $statement The SQL statement.
|
||||
* @param \Doctrine\DBAL\Driver\OCI8\OCI8Connection $conn
|
||||
* @param resource $dbh The connection handle.
|
||||
* @param string $statement The SQL statement.
|
||||
*/
|
||||
public function __construct($dbh, $statement, OCI8Connection $conn)
|
||||
{
|
||||
list($statement, $paramMap) = self::convertPositionalToNamedPlaceholders($statement);
|
||||
$this->_sth = oci_parse($dbh, $statement);
|
||||
$this->_dbh = $dbh;
|
||||
$this->_paramMap = $paramMap;
|
||||
$this->_conn = $conn;
|
||||
[$statement, $paramMap] = self::convertPositionalToNamedPlaceholders($statement);
|
||||
$this->_sth = oci_parse($dbh, $statement);
|
||||
$this->_dbh = $dbh;
|
||||
$this->_paramMap = $paramMap;
|
||||
$this->_conn = $conn;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,22 +116,23 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
* Question marks inside literal strings are therefore handled correctly by this method.
|
||||
* This comes at a cost, the whole sql statement has to be looped over.
|
||||
*
|
||||
* @todo extract into utility class in Doctrine\DBAL\Util namespace
|
||||
* @todo review and test for lost spaces. we experienced missing spaces with oci8 in some sql statements.
|
||||
*
|
||||
* @param string $statement The SQL statement to convert.
|
||||
*
|
||||
* @return array [0] => the statement value (string), [1] => the paramMap value (array).
|
||||
* @throws \Doctrine\DBAL\Driver\OCI8\OCI8Exception
|
||||
* @return mixed[] [0] => the statement value (string), [1] => the paramMap value (array).
|
||||
*
|
||||
* @throws OCI8Exception
|
||||
*
|
||||
* @todo extract into utility class in Doctrine\DBAL\Util namespace
|
||||
* @todo review and test for lost spaces. we experienced missing spaces with oci8 in some sql statements.
|
||||
*/
|
||||
public static function convertPositionalToNamedPlaceholders($statement)
|
||||
{
|
||||
$fragmentOffset = $tokenOffset = 0;
|
||||
$fragments = $paramMap = [];
|
||||
$fragmentOffset = $tokenOffset = 0;
|
||||
$fragments = $paramMap = [];
|
||||
$currentLiteralDelimiter = null;
|
||||
|
||||
do {
|
||||
if (!$currentLiteralDelimiter) {
|
||||
if (! $currentLiteralDelimiter) {
|
||||
$result = self::findPlaceholderOrOpeningQuote(
|
||||
$statement,
|
||||
$tokenOffset,
|
||||
@@ -186,7 +154,7 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
}
|
||||
|
||||
$fragments[] = substr($statement, $fragmentOffset);
|
||||
$statement = implode('', $fragments);
|
||||
$statement = implode('', $fragments);
|
||||
|
||||
return [$statement, $paramMap];
|
||||
}
|
||||
@@ -201,6 +169,7 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
* @param string|null $currentLiteralDelimiter The delimiter of the current string literal
|
||||
* or NULL if not currently in a literal
|
||||
* @param array<int, string> $paramMap Mapping of the original parameter positions to their named replacements
|
||||
*
|
||||
* @return bool Whether the token was found
|
||||
*/
|
||||
private static function findPlaceholderOrOpeningQuote(
|
||||
@@ -213,18 +182,18 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
) {
|
||||
$token = self::findToken($statement, $tokenOffset, '/[?\'"]/');
|
||||
|
||||
if (!$token) {
|
||||
if (! $token) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($token === '?') {
|
||||
$position = count($paramMap) + 1;
|
||||
$param = ':param' . $position;
|
||||
$fragments[] = substr($statement, $fragmentOffset, $tokenOffset - $fragmentOffset);
|
||||
$fragments[] = $param;
|
||||
$position = count($paramMap) + 1;
|
||||
$param = ':param' . $position;
|
||||
$fragments[] = substr($statement, $fragmentOffset, $tokenOffset - $fragmentOffset);
|
||||
$fragments[] = $param;
|
||||
$paramMap[$position] = $param;
|
||||
$tokenOffset += 1;
|
||||
$fragmentOffset = $tokenOffset;
|
||||
$tokenOffset += 1;
|
||||
$fragmentOffset = $tokenOffset;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -242,6 +211,7 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
* @param string $tokenOffset The offset to start searching from
|
||||
* @param string|null $currentLiteralDelimiter The delimiter of the current string literal
|
||||
* or NULL if not currently in a literal
|
||||
*
|
||||
* @return bool Whether the token was found
|
||||
*/
|
||||
private static function findClosingQuote(
|
||||
@@ -255,7 +225,7 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
'/' . preg_quote($currentLiteralDelimiter, '/') . '/'
|
||||
);
|
||||
|
||||
if (!$token) {
|
||||
if (! $token) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -272,6 +242,7 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
* @param string $statement The SQL statement to parse
|
||||
* @param string $offset The offset to start searching from
|
||||
* @param string $regex The regex containing token pattern
|
||||
*
|
||||
* @return string|null Token or NULL if not found
|
||||
*/
|
||||
private static function findToken($statement, &$offset, $regex)
|
||||
@@ -340,7 +311,7 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
public function closeCursor()
|
||||
{
|
||||
// not having the result means there's nothing to close
|
||||
if (!$this->result) {
|
||||
if (! $this->result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -397,7 +368,7 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
}
|
||||
|
||||
$ret = @oci_execute($this->_sth, $this->_conn->getExecuteMode());
|
||||
if ( ! $ret) {
|
||||
if (! $ret) {
|
||||
throw OCI8Exception::fromErrorInfo($this->errorInfo());
|
||||
}
|
||||
|
||||
@@ -427,11 +398,11 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
// do not try fetching from the statement if it's not expected to contain result
|
||||
// in order to prevent exceptional situation
|
||||
if (!$this->result) {
|
||||
if (! $this->result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -446,7 +417,7 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
}
|
||||
|
||||
if (! isset(self::$fetchModeMap[$fetchMode])) {
|
||||
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchMode);
|
||||
throw new InvalidArgumentException('Invalid fetch style: ' . $fetchMode);
|
||||
}
|
||||
|
||||
return oci_fetch_array(
|
||||
@@ -472,8 +443,8 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ( ! isset(self::$fetchModeMap[$fetchMode])) {
|
||||
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchMode);
|
||||
if (! isset(self::$fetchModeMap[$fetchMode])) {
|
||||
throw new InvalidArgumentException('Invalid fetch style: ' . $fetchMode);
|
||||
}
|
||||
|
||||
if (self::$fetchModeMap[$fetchMode] === OCI_BOTH) {
|
||||
@@ -489,12 +460,17 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
|
||||
// do not try fetching from the statement if it's not expected to contain result
|
||||
// in order to prevent exceptional situation
|
||||
if (!$this->result) {
|
||||
if (! $this->result) {
|
||||
return [];
|
||||
}
|
||||
|
||||
oci_fetch_all($this->_sth, $result, 0, -1,
|
||||
self::$fetchModeMap[$fetchMode] | OCI_RETURN_NULLS | $fetchStructure | OCI_RETURN_LOBS);
|
||||
oci_fetch_all(
|
||||
$this->_sth,
|
||||
$result,
|
||||
0,
|
||||
-1,
|
||||
self::$fetchModeMap[$fetchMode] | OCI_RETURN_NULLS | $fetchStructure | OCI_RETURN_LOBS
|
||||
);
|
||||
|
||||
if ($fetchMode === FetchMode::COLUMN) {
|
||||
$result = $result[0];
|
||||
@@ -511,13 +487,13 @@ class OCI8Statement implements IteratorAggregate, Statement
|
||||
{
|
||||
// do not try fetching from the statement if it's not expected to contain result
|
||||
// in order to prevent exceptional situation
|
||||
if (!$this->result) {
|
||||
if (! $this->result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$row = oci_fetch_array($this->_sth, OCI_NUM | OCI_RETURN_NULLS | OCI_RETURN_LOBS);
|
||||
|
||||
if (false === $row) {
|
||||
if ($row === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
@@ -27,24 +10,22 @@ use function func_get_args;
|
||||
/**
|
||||
* PDO implementation of the Connection interface.
|
||||
* Used by all PDO-based drivers.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
|
||||
{
|
||||
/**
|
||||
* @param string $dsn
|
||||
* @param string|null $user
|
||||
* @param string|null $password
|
||||
* @param array|null $options
|
||||
* @param string $dsn
|
||||
* @param string|null $user
|
||||
* @param string|null $password
|
||||
* @param mixed[]|null $options
|
||||
*
|
||||
* @throws PDOException in case of an error.
|
||||
* @throws PDOException In case of an error.
|
||||
*/
|
||||
public function __construct($dsn, $user = null, $password = null, array $options = null)
|
||||
public function __construct($dsn, $user = null, $password = null, ?array $options = null)
|
||||
{
|
||||
try {
|
||||
parent::__construct($dsn, $user, $password, $options);
|
||||
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, ['Doctrine\DBAL\Driver\PDOStatement', []]);
|
||||
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, [PDOStatement::class, []]);
|
||||
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (\PDOException $exception) {
|
||||
throw new PDOException($exception);
|
||||
@@ -88,19 +69,19 @@ class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$args = func_get_args();
|
||||
$argsCount = count($args);
|
||||
|
||||
try {
|
||||
if ($argsCount == 4) {
|
||||
if ($argsCount === 4) {
|
||||
return parent::query($args[0], $args[1], $args[2], $args[3]);
|
||||
}
|
||||
|
||||
if ($argsCount == 3) {
|
||||
if ($argsCount === 3) {
|
||||
return parent::query($args[0], $args[1], $args[2]);
|
||||
}
|
||||
|
||||
if ($argsCount == 2) {
|
||||
if ($argsCount === 2) {
|
||||
return parent::query($args[0], $args[1]);
|
||||
}
|
||||
|
||||
@@ -123,7 +104,11 @@ class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function lastInsertId($name = null)
|
||||
{
|
||||
return parent::lastInsertId($name);
|
||||
try {
|
||||
return parent::lastInsertId($name);
|
||||
} catch (\PDOException $exception) {
|
||||
throw new PDOException($exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,30 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
/**
|
||||
* Tiny wrapper for PDOException instances to implement the {@link DriverException} interface.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class PDOException extends \PDOException implements DriverException
|
||||
{
|
||||
@@ -43,8 +22,6 @@ class PDOException extends \PDOException implements DriverException
|
||||
private $sqlState;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \PDOException $exception The PDO exception to wrap.
|
||||
*/
|
||||
public function __construct(\PDOException $exception)
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\PDOIbm;
|
||||
|
||||
@@ -24,13 +7,6 @@ use Doctrine\DBAL\Driver\PDOConnection;
|
||||
|
||||
/**
|
||||
* Driver for the PDO IBM extension.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
class Driver extends AbstractDB2Driver
|
||||
{
|
||||
@@ -39,20 +15,18 @@ class Driver extends AbstractDB2Driver
|
||||
*/
|
||||
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
|
||||
{
|
||||
$conn = new PDOConnection(
|
||||
return new PDOConnection(
|
||||
$this->_constructPdoDsn($params),
|
||||
$username,
|
||||
$password,
|
||||
$driverOptions
|
||||
);
|
||||
|
||||
return $conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the IBM PDO DSN.
|
||||
*
|
||||
* @param array $params
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return string The DSN.
|
||||
*/
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\PDOMySql;
|
||||
|
||||
@@ -26,8 +9,6 @@ use PDOException;
|
||||
|
||||
/**
|
||||
* PDO MySql driver.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
class Driver extends AbstractMySQLDriver
|
||||
{
|
||||
@@ -53,14 +34,14 @@ class Driver extends AbstractMySQLDriver
|
||||
/**
|
||||
* Constructs the MySql PDO DSN.
|
||||
*
|
||||
* @param array $params
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return string The DSN.
|
||||
*/
|
||||
protected function constructPdoDsn(array $params)
|
||||
{
|
||||
$dsn = 'mysql:';
|
||||
if (isset($params['host']) && $params['host'] != '') {
|
||||
if (isset($params['host']) && $params['host'] !== '') {
|
||||
$dsn .= 'host=' . $params['host'] . ';';
|
||||
}
|
||||
if (isset($params['port'])) {
|
||||
|
@@ -1,27 +1,11 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\PDOOracle;
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\AbstractOracleDriver;
|
||||
use Doctrine\DBAL\Driver\PDOConnection;
|
||||
use PDOException;
|
||||
|
||||
/**
|
||||
* PDO Oracle driver.
|
||||
@@ -45,7 +29,7 @@ class Driver extends AbstractOracleDriver
|
||||
$password,
|
||||
$driverOptions
|
||||
);
|
||||
} catch (\PDOException $e) {
|
||||
} catch (PDOException $e) {
|
||||
throw DBALException::driverException($this, $e);
|
||||
}
|
||||
}
|
||||
@@ -53,7 +37,7 @@ class Driver extends AbstractOracleDriver
|
||||
/**
|
||||
* Constructs the Oracle PDO DSN.
|
||||
*
|
||||
* @param array $params
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return string The DSN.
|
||||
*/
|
||||
|
@@ -1,35 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\PDOPgSql;
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
|
||||
use Doctrine\DBAL\Driver\PDOConnection;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use PDOException;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use function defined;
|
||||
|
||||
/**
|
||||
* Driver that connects through pdo_pgsql.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
class Driver extends AbstractPostgreSQLDriver
|
||||
{
|
||||
@@ -48,7 +29,7 @@ class Driver extends AbstractPostgreSQLDriver
|
||||
|
||||
if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')
|
||||
&& (! isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES])
|
||||
|| true === $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES]
|
||||
|| $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES] === true
|
||||
)
|
||||
) {
|
||||
$pdo->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true);
|
||||
@@ -71,7 +52,7 @@ class Driver extends AbstractPostgreSQLDriver
|
||||
/**
|
||||
* Constructs the Postgres PDO DSN.
|
||||
*
|
||||
* @param array $params
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return string The DSN.
|
||||
*/
|
||||
@@ -79,11 +60,11 @@ class Driver extends AbstractPostgreSQLDriver
|
||||
{
|
||||
$dsn = 'pgsql:';
|
||||
|
||||
if (isset($params['host']) && $params['host'] != '') {
|
||||
if (isset($params['host']) && $params['host'] !== '') {
|
||||
$dsn .= 'host=' . $params['host'] . ';';
|
||||
}
|
||||
|
||||
if (isset($params['port']) && $params['port'] != '') {
|
||||
if (isset($params['port']) && $params['port'] !== '') {
|
||||
$dsn .= 'port=' . $params['port'] . ';';
|
||||
}
|
||||
|
||||
@@ -95,7 +76,7 @@ class Driver extends AbstractPostgreSQLDriver
|
||||
// Used for temporary connections to allow operations like dropping the database currently connected to.
|
||||
// Connecting without an explicit database does not work, therefore "postgres" database is used
|
||||
// as it is mostly present in every server setup.
|
||||
$dsn .= 'dbname=postgres' . ';';
|
||||
$dsn .= 'dbname=postgres;';
|
||||
}
|
||||
|
||||
if (isset($params['sslmode'])) {
|
||||
|
@@ -1,44 +1,24 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\PDOSqlite;
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
|
||||
use Doctrine\DBAL\Driver\PDOConnection;
|
||||
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
||||
use PDOException;
|
||||
use function array_merge;
|
||||
|
||||
/**
|
||||
* The PDO Sqlite driver.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
class Driver extends AbstractSQLiteDriver
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var mixed[] */
|
||||
protected $_userDefinedFunctions = [
|
||||
'sqrt' => ['callback' => ['Doctrine\DBAL\Platforms\SqlitePlatform', 'udfSqrt'], 'numArgs' => 1],
|
||||
'mod' => ['callback' => ['Doctrine\DBAL\Platforms\SqlitePlatform', 'udfMod'], 'numArgs' => 2],
|
||||
'locate' => ['callback' => ['Doctrine\DBAL\Platforms\SqlitePlatform', 'udfLocate'], 'numArgs' => -1],
|
||||
'sqrt' => ['callback' => [SqlitePlatform::class, 'udfSqrt'], 'numArgs' => 1],
|
||||
'mod' => ['callback' => [SqlitePlatform::class, 'udfMod'], 'numArgs' => 2],
|
||||
'locate' => ['callback' => [SqlitePlatform::class, 'udfLocate'], 'numArgs' => -1],
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -48,7 +28,9 @@ class Driver extends AbstractSQLiteDriver
|
||||
{
|
||||
if (isset($driverOptions['userDefinedFunctions'])) {
|
||||
$this->_userDefinedFunctions = array_merge(
|
||||
$this->_userDefinedFunctions, $driverOptions['userDefinedFunctions']);
|
||||
$this->_userDefinedFunctions,
|
||||
$driverOptions['userDefinedFunctions']
|
||||
);
|
||||
unset($driverOptions['userDefinedFunctions']);
|
||||
}
|
||||
|
||||
@@ -73,7 +55,7 @@ class Driver extends AbstractSQLiteDriver
|
||||
/**
|
||||
* Constructs the Sqlite PDO DSN.
|
||||
*
|
||||
* @param array $params
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return string The DSN.
|
||||
*/
|
||||
|
@@ -1,43 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\PDOSqlsrv;
|
||||
|
||||
use Doctrine\DBAL\Driver\PDOConnection;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use PDO;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* Sqlsrv Connection implementation.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
class Connection extends PDOConnection implements \Doctrine\DBAL\Driver\Connection
|
||||
class Connection extends PDOConnection
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($dsn, $user = null, $password = null, array $options = null)
|
||||
public function __construct($dsn, $user = null, $password = null, ?array $options = null)
|
||||
{
|
||||
parent::__construct($dsn, $user, $password, $options);
|
||||
$this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [Statement::class, []]);
|
||||
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, [Statement::class, []]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +27,7 @@ class Connection extends PDOConnection implements \Doctrine\DBAL\Driver\Connecti
|
||||
*/
|
||||
public function lastInsertId($name = null)
|
||||
{
|
||||
if (null === $name) {
|
||||
if ($name === null) {
|
||||
return parent::lastInsertId($name);
|
||||
}
|
||||
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\PDOSqlsrv;
|
||||
|
||||
@@ -25,8 +8,6 @@ use function sprintf;
|
||||
|
||||
/**
|
||||
* The PDO-based Sqlsrv driver.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
class Driver extends AbstractSQLServerDriver
|
||||
{
|
||||
@@ -48,7 +29,7 @@ class Driver extends AbstractSQLServerDriver
|
||||
/**
|
||||
* Constructs the Sqlsrv PDO DSN.
|
||||
*
|
||||
* @param array $params
|
||||
* @param mixed[] $params
|
||||
* @param string[] $connectionOptions
|
||||
*
|
||||
* @return string The DSN.
|
||||
@@ -61,7 +42,7 @@ class Driver extends AbstractSQLServerDriver
|
||||
$dsn .= $params['host'];
|
||||
}
|
||||
|
||||
if (isset($params['port']) && !empty($params['port'])) {
|
||||
if (isset($params['port']) && ! empty($params['port'])) {
|
||||
$dsn .= ',' . $params['port'];
|
||||
}
|
||||
|
||||
@@ -73,15 +54,14 @@ class Driver extends AbstractSQLServerDriver
|
||||
$connectionOptions['MultipleActiveResultSets'] = $params['MultipleActiveResultSets'] ? 'true' : 'false';
|
||||
}
|
||||
|
||||
$dsn .= $this->getConnectionOptionsDsn($connectionOptions);
|
||||
|
||||
return $dsn;
|
||||
return $dsn . $this->getConnectionOptionsDsn($connectionOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Separates a connection options from a driver options
|
||||
*
|
||||
* @param int[]|string[] $options
|
||||
*
|
||||
* @return int[][]|string[][]
|
||||
*/
|
||||
private function splitOptions(array $options) : array
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\PDOSqlsrv;
|
||||
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
@@ -29,14 +12,9 @@ use function trigger_error;
|
||||
/**
|
||||
* The PDO implementation of the Statement interface.
|
||||
* Used by all PDO-based drivers.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
class PDOStatement extends \PDOStatement implements Statement
|
||||
{
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
private const PARAM_TYPE_MAP = [
|
||||
ParameterType::NULL => PDO::PARAM_NULL,
|
||||
ParameterType::INTEGER => PDO::PARAM_INT,
|
||||
@@ -46,9 +24,6 @@ class PDOStatement extends \PDOStatement implements Statement
|
||||
ParameterType::BOOLEAN => PDO::PARAM_BOOL,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
private const FETCH_MODE_MAP = [
|
||||
FetchMode::ASSOCIATIVE => PDO::FETCH_ASSOC,
|
||||
FetchMode::NUMERIC => PDO::FETCH_NUM,
|
||||
@@ -148,20 +123,20 @@ class PDOStatement extends \PDOStatement implements Statement
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
$fetchMode = $this->convertFetchMode($fetchMode);
|
||||
|
||||
try {
|
||||
if ($fetchMode === null && \PDO::FETCH_ORI_NEXT === $cursorOrientation && 0 === $cursorOffset) {
|
||||
if ($fetchMode === null && $cursorOrientation === PDO::FETCH_ORI_NEXT && $cursorOffset === 0) {
|
||||
return parent::fetch();
|
||||
}
|
||||
|
||||
if (\PDO::FETCH_ORI_NEXT === $cursorOrientation && 0 === $cursorOffset) {
|
||||
if ($cursorOrientation === PDO::FETCH_ORI_NEXT && $cursorOffset === 0) {
|
||||
return parent::fetch($fetchMode);
|
||||
}
|
||||
|
||||
if (0 === $cursorOffset) {
|
||||
if ($cursorOffset === 0) {
|
||||
return parent::fetch($fetchMode, $cursorOrientation);
|
||||
}
|
||||
|
||||
@@ -179,15 +154,15 @@ class PDOStatement extends \PDOStatement implements Statement
|
||||
$fetchMode = $this->convertFetchMode($fetchMode);
|
||||
|
||||
try {
|
||||
if ($fetchMode === null && null === $fetchArgument && null === $ctorArgs) {
|
||||
if ($fetchMode === null && $fetchArgument === null && $ctorArgs === null) {
|
||||
return parent::fetchAll();
|
||||
}
|
||||
|
||||
if (null === $fetchArgument && null === $ctorArgs) {
|
||||
if ($fetchArgument === null && $ctorArgs === null) {
|
||||
return parent::fetchAll($fetchMode);
|
||||
}
|
||||
|
||||
if (null === $ctorArgs) {
|
||||
if ($ctorArgs === null) {
|
||||
return parent::fetchAll($fetchMode, $fetchArgument);
|
||||
}
|
||||
|
||||
|
@@ -1,31 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
/**
|
||||
* An interface for connections which support a "native" ping method.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
* @author Till Klampaeckel <till@php.net>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
interface PingableConnection
|
||||
{
|
||||
|
@@ -1,30 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use PDO;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* Interface for the reading part of a prepare statement only.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
interface ResultStatement extends \Traversable
|
||||
interface ResultStatement extends Traversable
|
||||
{
|
||||
/**
|
||||
* Closes the cursor, enabling the statement to be executed again.
|
||||
@@ -78,27 +62,27 @@ interface ResultStatement extends \Traversable
|
||||
* @return mixed The return value of this method on success depends on the fetch mode. In all cases, FALSE is
|
||||
* returned on failure.
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0);
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0);
|
||||
|
||||
/**
|
||||
* Returns an array containing all of the result set rows.
|
||||
*
|
||||
* @param int|null $fetchMode Controls how the next row will be returned to the caller.
|
||||
* The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
|
||||
* defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
|
||||
* @param int|null $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter:
|
||||
* * {@link \Doctrine\DBAL\FetchMode::COLUMN}:
|
||||
* Returns the indicated 0-indexed column.
|
||||
* * {@link \Doctrine\DBAL\FetchMode::CUSTOM_OBJECT}:
|
||||
* Returns instances of the specified class, mapping the columns of each row
|
||||
* to named properties in the class.
|
||||
* * \PDO::FETCH_FUNC: Returns the results of calling the specified function, using each row's
|
||||
* columns as parameters in the call.
|
||||
* @param array|null $ctorArgs Controls how the next row will be returned to the caller.
|
||||
* The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
|
||||
* defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
|
||||
* @param int|null $fetchMode Controls how the next row will be returned to the caller.
|
||||
* The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
|
||||
* defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
|
||||
* @param int|null $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter:
|
||||
* * {@link \Doctrine\DBAL\FetchMode::COLUMN}:
|
||||
* Returns the indicated 0-indexed column.
|
||||
* * {@link \Doctrine\DBAL\FetchMode::CUSTOM_OBJECT}:
|
||||
* Returns instances of the specified class, mapping the columns of each row
|
||||
* to named properties in the class.
|
||||
* * \PDO::FETCH_FUNC: Returns the results of calling the specified function, using each row's
|
||||
* columns as parameters in the call.
|
||||
* @param mixed[]|null $ctorArgs Controls how the next row will be returned to the caller.
|
||||
* The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
|
||||
* defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
|
||||
*
|
||||
* @return array
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null);
|
||||
|
||||
@@ -106,10 +90,9 @@ interface ResultStatement extends \Traversable
|
||||
* Returns a single column from the next row of a result set or FALSE if there are no more rows.
|
||||
*
|
||||
* @param int $columnIndex 0-indexed number of the column you wish to retrieve from the row.
|
||||
* If no value is supplied, PDOStatement->fetchColumn()
|
||||
* fetches the first column.
|
||||
* If no value is supplied, fetches the first column.
|
||||
*
|
||||
* @return string|boolean A single column in the next row of a result set, or FALSE if there are no more rows.
|
||||
* @return mixed|false A single column in the next row of a result set, or FALSE if there are no more rows.
|
||||
*/
|
||||
public function fetchColumn($columnIndex = 0);
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLAnywhere;
|
||||
|
||||
@@ -27,17 +10,13 @@ use function implode;
|
||||
|
||||
/**
|
||||
* A Doctrine DBAL driver for the SAP Sybase SQL Anywhere PHP extension.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class Driver extends AbstractSQLAnywhereDriver
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws \Doctrine\DBAL\DBALException if there was a problem establishing the connection.
|
||||
* @throws DBALException If there was a problem establishing the connection.
|
||||
*/
|
||||
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
|
||||
{
|
||||
@@ -70,15 +49,15 @@ class Driver extends AbstractSQLAnywhereDriver
|
||||
/**
|
||||
* Build the connection string for given connection parameters and driver options.
|
||||
*
|
||||
* @param string $host Host address to connect to.
|
||||
* @param int $port Port to use for the connection (default to SQL Anywhere standard port 2638).
|
||||
* @param string $server Database server name on the host to connect to.
|
||||
* SQL Anywhere allows multiple database server instances on the same host,
|
||||
* therefore specifying the server instance name to use is mandatory.
|
||||
* @param string $dbname Name of the database on the server instance to connect to.
|
||||
* @param string $username User name to use for connection authentication.
|
||||
* @param string $password Password to use for connection authentication.
|
||||
* @param array $driverOptions Additional parameters to use for the connection.
|
||||
* @param string $host Host address to connect to.
|
||||
* @param int $port Port to use for the connection (default to SQL Anywhere standard port 2638).
|
||||
* @param string $server Database server name on the host to connect to.
|
||||
* SQL Anywhere allows multiple database server instances on the same host,
|
||||
* therefore specifying the server instance name to use is mandatory.
|
||||
* @param string $dbname Name of the database on the server instance to connect to.
|
||||
* @param string $username User name to use for connection authentication.
|
||||
* @param string $password Password to use for connection authentication.
|
||||
* @param mixed[] $driverOptions Additional parameters to use for the connection.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -91,15 +70,14 @@ class Driver extends AbstractSQLAnywhereDriver
|
||||
$server = ';ServerName=' . $server;
|
||||
}
|
||||
|
||||
return
|
||||
'HOST=' . $host . ':' . $port .
|
||||
return 'HOST=' . $host . ':' . $port .
|
||||
$server .
|
||||
';DBN=' . $dbname .
|
||||
';UID=' . $username .
|
||||
';PWD=' . $password .
|
||||
';' . implode(
|
||||
';',
|
||||
array_map(function ($key, $value) {
|
||||
array_map(static function ($key, $value) {
|
||||
return $key . '=' . $value;
|
||||
}, array_keys($driverOptions), $driverOptions)
|
||||
);
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLAnywhere;
|
||||
|
||||
@@ -42,21 +25,13 @@ use function sasql_set_option;
|
||||
|
||||
/**
|
||||
* SAP Sybase SQL Anywhere implementation of the Connection interface.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
{
|
||||
/**
|
||||
* @var resource The SQL Anywhere connection resource.
|
||||
*/
|
||||
/** @var resource The SQL Anywhere connection resource. */
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Connects to database with given connection string.
|
||||
*
|
||||
* @param string $dsn The connection string.
|
||||
@@ -68,22 +43,17 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
{
|
||||
$this->connection = $persistent ? @sasql_pconnect($dsn) : @sasql_connect($dsn);
|
||||
|
||||
if ( ! is_resource($this->connection)) {
|
||||
if (! is_resource($this->connection)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError();
|
||||
}
|
||||
|
||||
// Disable PHP warnings on error.
|
||||
if ( ! sasql_set_option($this->connection, 'verbose_errors', false)) {
|
||||
if (! sasql_set_option($this->connection, 'verbose_errors', false)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
// Enable auto committing by default.
|
||||
if ( ! sasql_set_option($this->connection, 'auto_commit', 'on')) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
// Enable exact, non-approximated row count retrieval.
|
||||
if ( ! sasql_set_option($this->connection, 'row_counts', true)) {
|
||||
if (! sasql_set_option($this->connection, 'auto_commit', 'on')) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +65,7 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
if ( ! sasql_set_option($this->connection, 'auto_commit', 'off')) {
|
||||
if (! sasql_set_option($this->connection, 'auto_commit', 'off')) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
@@ -109,7 +79,7 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
if ( ! sasql_commit($this->connection)) {
|
||||
if (! sasql_commit($this->connection)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
@@ -139,7 +109,7 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function exec($statement)
|
||||
{
|
||||
if (false === sasql_real_query($this->connection, $statement)) {
|
||||
if (sasql_real_query($this->connection, $statement) === false) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
@@ -163,7 +133,7 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function lastInsertId($name = null)
|
||||
{
|
||||
if (null === $name) {
|
||||
if ($name === null) {
|
||||
return sasql_insert_id($this->connection);
|
||||
}
|
||||
|
||||
@@ -218,7 +188,7 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function rollBack()
|
||||
{
|
||||
if ( ! sasql_rollback($this->connection)) {
|
||||
if (! sasql_rollback($this->connection)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
@@ -230,13 +200,13 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
/**
|
||||
* Ends transactional mode and enables auto commit again.
|
||||
*
|
||||
* @throws SQLAnywhereException
|
||||
*
|
||||
* @return bool Whether or not ending transactional mode succeeded.
|
||||
*
|
||||
* @throws SQLAnywhereException
|
||||
*/
|
||||
private function endTransaction()
|
||||
{
|
||||
if ( ! sasql_set_option($this->connection, 'auto_commit', 'on')) {
|
||||
if (! sasql_set_option($this->connection, 'auto_commit', 'on')) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
|
@@ -1,25 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLAnywhere;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractDriverException;
|
||||
use InvalidArgumentException;
|
||||
use function is_resource;
|
||||
use function sasql_error;
|
||||
use function sasql_errorcode;
|
||||
@@ -29,10 +13,6 @@ use function sasql_stmt_error;
|
||||
|
||||
/**
|
||||
* SAP Sybase SQL Anywhere driver exception.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class SQLAnywhereException extends AbstractDriverException
|
||||
{
|
||||
@@ -44,16 +24,16 @@ class SQLAnywhereException extends AbstractDriverException
|
||||
*
|
||||
* @return SQLAnywhereException
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function fromSQLAnywhereError($conn = null, $stmt = null)
|
||||
{
|
||||
if (null !== $conn && ! (is_resource($conn))) {
|
||||
throw new \InvalidArgumentException('Invalid SQL Anywhere connection resource given: ' . $conn);
|
||||
if ($conn !== null && ! is_resource($conn)) {
|
||||
throw new InvalidArgumentException('Invalid SQL Anywhere connection resource given: ' . $conn);
|
||||
}
|
||||
|
||||
if (null !== $stmt && ! (is_resource($stmt))) {
|
||||
throw new \InvalidArgumentException('Invalid SQL Anywhere statement resource given: ' . $stmt);
|
||||
if ($stmt !== null && ! is_resource($stmt)) {
|
||||
throw new InvalidArgumentException('Invalid SQL Anywhere statement resource given: ' . $stmt);
|
||||
}
|
||||
|
||||
$state = $conn ? sasql_sqlstate($conn) : sasql_sqlstate();
|
||||
@@ -86,7 +66,7 @@ class SQLAnywhereException extends AbstractDriverException
|
||||
* or the last error could not be retrieved from the given
|
||||
* connection / statement resource.
|
||||
*/
|
||||
if ( ! $conn || ! $code) {
|
||||
if (! $conn || ! $code) {
|
||||
$code = sasql_errorcode();
|
||||
$message = sasql_error();
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLAnywhere;
|
||||
|
||||
@@ -24,9 +7,12 @@ use Doctrine\DBAL\Driver\StatementIterator;
|
||||
use Doctrine\DBAL\FetchMode;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use IteratorAggregate;
|
||||
use PDO;
|
||||
use ReflectionClass;
|
||||
use ReflectionObject;
|
||||
use stdClass;
|
||||
use const SASQL_BOTH;
|
||||
use function array_key_exists;
|
||||
use function call_user_func_array;
|
||||
use function func_get_args;
|
||||
use function func_num_args;
|
||||
use function gettype;
|
||||
@@ -52,46 +38,28 @@ use function sprintf;
|
||||
|
||||
/**
|
||||
* SAP SQL Anywhere implementation of the Statement interface.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
{
|
||||
/**
|
||||
* @var resource The connection resource.
|
||||
*/
|
||||
/** @var resource The connection resource. */
|
||||
private $conn;
|
||||
|
||||
/**
|
||||
* @var string Name of the default class to instantiate when fetching class instances.
|
||||
*/
|
||||
/** @var string Name of the default class to instantiate when fetching class instances. */
|
||||
private $defaultFetchClass = '\stdClass';
|
||||
|
||||
/**
|
||||
* @var mixed[] Constructor arguments for the default class to instantiate when fetching class instances.
|
||||
*/
|
||||
/** @var mixed[] Constructor arguments for the default class to instantiate when fetching class instances. */
|
||||
private $defaultFetchClassCtorArgs = [];
|
||||
|
||||
/**
|
||||
* @var int Default fetch mode to use.
|
||||
*/
|
||||
/** @var int Default fetch mode to use. */
|
||||
private $defaultFetchMode = FetchMode::MIXED;
|
||||
|
||||
/**
|
||||
* @var resource The result set resource to fetch.
|
||||
*/
|
||||
/** @var resource The result set resource to fetch. */
|
||||
private $result;
|
||||
|
||||
/**
|
||||
* @var resource The prepared SQL statement to execute.
|
||||
*/
|
||||
/** @var resource The prepared SQL statement to execute. */
|
||||
private $stmt;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Prepares given statement for given connection.
|
||||
*
|
||||
* @param resource $conn The connection resource to use.
|
||||
@@ -101,14 +69,14 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
*/
|
||||
public function __construct($conn, $sql)
|
||||
{
|
||||
if ( ! is_resource($conn)) {
|
||||
if (! is_resource($conn)) {
|
||||
throw new SQLAnywhereException('Invalid SQL Anywhere connection resource: ' . $conn);
|
||||
}
|
||||
|
||||
$this->conn = $conn;
|
||||
$this->stmt = sasql_prepare($conn, $sql);
|
||||
|
||||
if ( ! is_resource($this->stmt)) {
|
||||
if (! is_resource($this->stmt)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($conn);
|
||||
}
|
||||
}
|
||||
@@ -140,7 +108,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
throw new SQLAnywhereException('Unknown type: ' . $type);
|
||||
}
|
||||
|
||||
if ( ! sasql_stmt_bind_param_ex($this->stmt, $column - 1, $variable, $type, $variable === null)) {
|
||||
if (! sasql_stmt_bind_param_ex($this->stmt, $column - 1, $variable, $type, $variable === null)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->conn, $this->stmt);
|
||||
}
|
||||
|
||||
@@ -162,7 +130,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
*/
|
||||
public function closeCursor()
|
||||
{
|
||||
if (!sasql_stmt_reset($this->stmt)) {
|
||||
if (! sasql_stmt_reset($this->stmt)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->conn, $this->stmt);
|
||||
}
|
||||
|
||||
@@ -204,13 +172,13 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
$hasZeroIndex = array_key_exists(0, $params);
|
||||
|
||||
foreach ($params as $key => $val) {
|
||||
$key = ($hasZeroIndex && is_numeric($key)) ? $key + 1 : $key;
|
||||
$key = $hasZeroIndex && is_numeric($key) ? $key + 1 : $key;
|
||||
|
||||
$this->bindValue($key, $val);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! sasql_stmt_execute($this->stmt)) {
|
||||
if (! sasql_stmt_execute($this->stmt)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->conn, $this->stmt);
|
||||
}
|
||||
|
||||
@@ -224,9 +192,9 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
*
|
||||
* @throws SQLAnywhereException
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
if ( ! is_resource($this->result)) {
|
||||
if (! is_resource($this->result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -254,7 +222,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
|
||||
$result = sasql_fetch_object($this->result);
|
||||
|
||||
if ($result instanceof \stdClass) {
|
||||
if ($result instanceof stdClass) {
|
||||
$result = $this->castObject($result, $className, $ctorArgs);
|
||||
}
|
||||
|
||||
@@ -280,7 +248,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
|
||||
switch ($fetchMode) {
|
||||
case FetchMode::CUSTOM_OBJECT:
|
||||
while ($row = call_user_func_array([$this, 'fetch'], func_get_args())) {
|
||||
while ($row = $this->fetch(...func_get_args())) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
break;
|
||||
@@ -307,7 +275,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
{
|
||||
$row = $this->fetch(FetchMode::NUMERIC);
|
||||
|
||||
if (false === $row) {
|
||||
if ($row === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -343,29 +311,30 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
/**
|
||||
* Casts a stdClass object to the given class name mapping its' properties.
|
||||
*
|
||||
* @param \stdClass $sourceObject Object to cast from.
|
||||
* @param stdClass $sourceObject Object to cast from.
|
||||
* @param string|object $destinationClass Name of the class or class instance to cast to.
|
||||
* @param array $ctorArgs Arguments to use for constructing the destination class instance.
|
||||
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @throws SQLAnywhereException
|
||||
*/
|
||||
private function castObject(\stdClass $sourceObject, $destinationClass, array $ctorArgs = [])
|
||||
private function castObject(stdClass $sourceObject, $destinationClass, array $ctorArgs = [])
|
||||
{
|
||||
if ( ! is_string($destinationClass)) {
|
||||
if ( ! is_object($destinationClass)) {
|
||||
if (! is_string($destinationClass)) {
|
||||
if (! is_object($destinationClass)) {
|
||||
throw new SQLAnywhereException(sprintf(
|
||||
'Destination class has to be of type string or object, %s given.', gettype($destinationClass)
|
||||
'Destination class has to be of type string or object, %s given.',
|
||||
gettype($destinationClass)
|
||||
));
|
||||
}
|
||||
} else {
|
||||
$destinationClass = new \ReflectionClass($destinationClass);
|
||||
$destinationClass = new ReflectionClass($destinationClass);
|
||||
$destinationClass = $destinationClass->newInstanceArgs($ctorArgs);
|
||||
}
|
||||
|
||||
$sourceReflection = new \ReflectionObject($sourceObject);
|
||||
$destinationClassReflection = new \ReflectionObject($destinationClass);
|
||||
$sourceReflection = new ReflectionObject($sourceObject);
|
||||
$destinationClassReflection = new ReflectionObject($destinationClass);
|
||||
|
||||
foreach ($sourceReflection->getProperties() as $sourceProperty) {
|
||||
$sourceProperty->setAccessible(true);
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLSrv;
|
||||
|
||||
@@ -31,7 +14,7 @@ class Driver extends AbstractSQLServerDriver
|
||||
*/
|
||||
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
|
||||
{
|
||||
if (!isset($params['host'])) {
|
||||
if (! isset($params['host'])) {
|
||||
throw new SQLSrvException("Missing 'host' in configuration for sqlsrv driver.");
|
||||
}
|
||||
|
||||
@@ -43,15 +26,20 @@ class Driver extends AbstractSQLServerDriver
|
||||
if (isset($params['dbname'])) {
|
||||
$driverOptions['Database'] = $params['dbname'];
|
||||
}
|
||||
|
||||
|
||||
if (isset($params['charset'])) {
|
||||
$driverOptions['CharacterSet'] = $params['charset'];
|
||||
}
|
||||
|
||||
$driverOptions['UID'] = $username;
|
||||
$driverOptions['PWD'] = $password;
|
||||
if ($username !== null) {
|
||||
$driverOptions['UID'] = $username;
|
||||
}
|
||||
|
||||
if (!isset($driverOptions['ReturnDatesAsStrings'])) {
|
||||
if ($password !== null) {
|
||||
$driverOptions['PWD'] = $password;
|
||||
}
|
||||
|
||||
if (! isset($driverOptions['ReturnDatesAsStrings'])) {
|
||||
$driverOptions['ReturnDatesAsStrings'] = 1;
|
||||
}
|
||||
|
||||
|
@@ -1,35 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLSrv;
|
||||
|
||||
/**
|
||||
* Last Id Data Container.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class LastInsertId
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/** @var int */
|
||||
private $id;
|
||||
|
||||
/**
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLSrv;
|
||||
|
||||
@@ -40,36 +23,29 @@ use function str_replace;
|
||||
|
||||
/**
|
||||
* SQL Server implementation for the Connection interface.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class SQLSrvConnection implements Connection, ServerInfoAwareConnection
|
||||
{
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
/** @var resource */
|
||||
protected $conn;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Driver\SQLSrv\LastInsertId
|
||||
*/
|
||||
/** @var LastInsertId */
|
||||
protected $lastInsertId;
|
||||
|
||||
/**
|
||||
* @param string $serverName
|
||||
* @param array $connectionOptions
|
||||
* @param string $serverName
|
||||
* @param mixed[] $connectionOptions
|
||||
*
|
||||
* @throws \Doctrine\DBAL\Driver\SQLSrv\SQLSrvException
|
||||
* @throws SQLSrvException
|
||||
*/
|
||||
public function __construct($serverName, $connectionOptions)
|
||||
{
|
||||
if ( ! sqlsrv_configure('WarningsReturnAsErrors', 0)) {
|
||||
if (! sqlsrv_configure('WarningsReturnAsErrors', 0)) {
|
||||
throw SQLSrvException::fromSqlSrvErrors();
|
||||
}
|
||||
|
||||
$this->conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
if ( ! $this->conn) {
|
||||
if (! $this->conn) {
|
||||
throw SQLSrvException::fromSqlSrvErrors();
|
||||
}
|
||||
$this->lastInsertId = new LastInsertId();
|
||||
@@ -107,7 +83,7 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
|
||||
public function query()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$sql = $args[0];
|
||||
$sql = $args[0];
|
||||
$stmt = $this->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
@@ -116,7 +92,6 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @license New BSD, code from Zend Framework
|
||||
*/
|
||||
public function quote($value, $type = ParameterType::STRING)
|
||||
{
|
||||
@@ -136,7 +111,7 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
|
||||
{
|
||||
$stmt = sqlsrv_query($this->conn, $statement);
|
||||
|
||||
if (false === $stmt) {
|
||||
if ($stmt === false) {
|
||||
throw SQLSrvException::fromSqlSrvErrors();
|
||||
}
|
||||
|
||||
@@ -163,7 +138,7 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
if ( ! sqlsrv_begin_transaction($this->conn)) {
|
||||
if (! sqlsrv_begin_transaction($this->conn)) {
|
||||
throw SQLSrvException::fromSqlSrvErrors();
|
||||
}
|
||||
}
|
||||
@@ -173,7 +148,7 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
if ( ! sqlsrv_commit($this->conn)) {
|
||||
if (! sqlsrv_commit($this->conn)) {
|
||||
throw SQLSrvException::fromSqlSrvErrors();
|
||||
}
|
||||
}
|
||||
@@ -183,7 +158,7 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function rollBack()
|
||||
{
|
||||
if ( ! sqlsrv_rollback($this->conn)) {
|
||||
if (! sqlsrv_rollback($this->conn)) {
|
||||
throw SQLSrvException::fromSqlSrvErrors();
|
||||
}
|
||||
}
|
||||
|
@@ -1,25 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLSrv;
|
||||
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractDriverException;
|
||||
use const SQLSRV_ERR_ERRORS;
|
||||
use function rtrim;
|
||||
@@ -34,24 +16,26 @@ class SQLSrvException extends AbstractDriverException
|
||||
*/
|
||||
public static function fromSqlSrvErrors()
|
||||
{
|
||||
$errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
|
||||
$message = "";
|
||||
$sqlState = null;
|
||||
$errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
|
||||
$message = '';
|
||||
$sqlState = null;
|
||||
$errorCode = null;
|
||||
|
||||
foreach ($errors as $error) {
|
||||
$message .= "SQLSTATE [".$error['SQLSTATE'].", ".$error['code']."]: ". $error['message']."\n";
|
||||
$message .= 'SQLSTATE [' . $error['SQLSTATE'] . ', ' . $error['code'] . ']: ' . $error['message'] . "\n";
|
||||
|
||||
if (null === $sqlState) {
|
||||
if ($sqlState === null) {
|
||||
$sqlState = $error['SQLSTATE'];
|
||||
}
|
||||
|
||||
if (null === $errorCode) {
|
||||
$errorCode = $error['code'];
|
||||
if ($errorCode !== null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$errorCode = $error['code'];
|
||||
}
|
||||
if ( ! $message) {
|
||||
$message = "SQL Server error occurred but no error message was retrieved from driver.";
|
||||
if (! $message) {
|
||||
$message = 'SQL Server error occurred but no error message was retrieved from driver.';
|
||||
}
|
||||
|
||||
return new self(rtrim($message), $sqlState, $errorCode);
|
||||
|
@@ -1,29 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLSrv;
|
||||
|
||||
use Doctrine\DBAL\Driver\Statement;
|
||||
use Doctrine\DBAL\Driver\StatementIterator;
|
||||
use Doctrine\DBAL\FetchMode;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use IteratorAggregate;
|
||||
use Doctrine\DBAL\Driver\Statement;
|
||||
use PDO;
|
||||
use const SQLSRV_ENC_BINARY;
|
||||
use const SQLSRV_ERR_ERRORS;
|
||||
use const SQLSRV_FETCH_ASSOC;
|
||||
@@ -52,9 +36,6 @@ use function stripos;
|
||||
|
||||
/**
|
||||
* SQL Server Statement.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
{
|
||||
@@ -82,21 +63,21 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
/**
|
||||
* References to the variables bound as statement parameters.
|
||||
*
|
||||
* @var array
|
||||
* @var mixed
|
||||
*/
|
||||
private $variables = [];
|
||||
|
||||
/**
|
||||
* Bound parameter types.
|
||||
*
|
||||
* @var array
|
||||
* @var int[]
|
||||
*/
|
||||
private $types = [];
|
||||
|
||||
/**
|
||||
* Translations.
|
||||
*
|
||||
* @var array
|
||||
* @var int[]
|
||||
*/
|
||||
private static $fetchMap = [
|
||||
FetchMode::MIXED => SQLSRV_FETCH_BOTH,
|
||||
@@ -128,7 +109,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
/**
|
||||
* The last insert ID.
|
||||
*
|
||||
* @var \Doctrine\DBAL\Driver\SQLSrv\LastInsertId|null
|
||||
* @var LastInsertId|null
|
||||
*/
|
||||
private $lastInsertId;
|
||||
|
||||
@@ -141,25 +122,24 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
|
||||
/**
|
||||
* Append to any INSERT query to retrieve the last insert id.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const LAST_INSERT_ID_SQL = ';SELECT SCOPE_IDENTITY() AS LastInsertId;';
|
||||
public const LAST_INSERT_ID_SQL = ';SELECT SCOPE_IDENTITY() AS LastInsertId;';
|
||||
|
||||
/**
|
||||
* @param resource $conn
|
||||
* @param string $sql
|
||||
* @param \Doctrine\DBAL\Driver\SQLSrv\LastInsertId|null $lastInsertId
|
||||
* @param resource $conn
|
||||
* @param string $sql
|
||||
*/
|
||||
public function __construct($conn, $sql, LastInsertId $lastInsertId = null)
|
||||
public function __construct($conn, $sql, ?LastInsertId $lastInsertId = null)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
$this->sql = $sql;
|
||||
$this->sql = $sql;
|
||||
|
||||
if (stripos($sql, 'INSERT INTO ') === 0) {
|
||||
$this->sql .= self::LAST_INSERT_ID_SQL;
|
||||
$this->lastInsertId = $lastInsertId;
|
||||
if (stripos($sql, 'INSERT INTO ') !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sql .= self::LAST_INSERT_ID_SQL;
|
||||
$this->lastInsertId = $lastInsertId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,14 +147,14 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
*/
|
||||
public function bindValue($param, $value, $type = ParameterType::STRING)
|
||||
{
|
||||
if (!is_numeric($param)) {
|
||||
if (! is_numeric($param)) {
|
||||
throw new SQLSrvException(
|
||||
'sqlsrv does not support named parameters to queries, use question mark (?) placeholders instead.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->variables[$param] = $value;
|
||||
$this->types[$param] = $type;
|
||||
$this->types[$param] = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,12 +162,12 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
*/
|
||||
public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null)
|
||||
{
|
||||
if (!is_numeric($column)) {
|
||||
throw new SQLSrvException("sqlsrv does not support named parameters to queries, use question mark (?) placeholders instead.");
|
||||
if (! is_numeric($column)) {
|
||||
throw new SQLSrvException('sqlsrv does not support named parameters to queries, use question mark (?) placeholders instead.');
|
||||
}
|
||||
|
||||
$this->variables[$column] =& $variable;
|
||||
$this->types[$column] = $type;
|
||||
$this->types[$column] = $type;
|
||||
|
||||
// unset the statement resource if it exists as the new one will need to be bound to the new variable
|
||||
$this->stmt = null;
|
||||
@@ -199,7 +179,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
public function closeCursor()
|
||||
{
|
||||
// not having the result means there's nothing to close
|
||||
if (!$this->result) {
|
||||
if (! $this->result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -207,7 +187,8 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
// @link http://php.net/manual/en/pdostatement.closecursor.php
|
||||
// @link https://github.com/php/php-src/blob/php-7.0.11/ext/pdo/pdo_stmt.c#L2075
|
||||
// deliberately do not consider multiple result sets, since doctrine/dbal doesn't support them
|
||||
while (sqlsrv_fetch($this->stmt));
|
||||
while (sqlsrv_fetch($this->stmt)) {
|
||||
}
|
||||
|
||||
$this->result = false;
|
||||
|
||||
@@ -251,16 +232,16 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
if ($params) {
|
||||
$hasZeroIndex = array_key_exists(0, $params);
|
||||
foreach ($params as $key => $val) {
|
||||
$key = ($hasZeroIndex && is_numeric($key)) ? $key + 1 : $key;
|
||||
$key = $hasZeroIndex && is_numeric($key) ? $key + 1 : $key;
|
||||
$this->bindValue($key, $val);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $this->stmt) {
|
||||
if (! $this->stmt) {
|
||||
$this->stmt = $this->prepare();
|
||||
}
|
||||
|
||||
if (!sqlsrv_execute($this->stmt)) {
|
||||
if (! sqlsrv_execute($this->stmt)) {
|
||||
throw SQLSrvException::fromSqlSrvErrors();
|
||||
}
|
||||
|
||||
@@ -277,6 +258,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
* Prepares SQL Server statement resource
|
||||
*
|
||||
* @return resource
|
||||
*
|
||||
* @throws SQLSrvException
|
||||
*/
|
||||
private function prepare()
|
||||
@@ -310,7 +292,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
|
||||
$stmt = sqlsrv_prepare($this->conn, $this->sql, $params);
|
||||
|
||||
if (!$stmt) {
|
||||
if (! $stmt) {
|
||||
throw SQLSrvException::fromSqlSrvErrors();
|
||||
}
|
||||
|
||||
@@ -342,11 +324,11 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
*
|
||||
* @throws SQLSrvException
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
// do not try fetching from the statement if it's not expected to contain result
|
||||
// in order to prevent exceptional situation
|
||||
if (!$this->result) {
|
||||
if (! $this->result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -412,7 +394,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
|
||||
{
|
||||
$row = $this->fetch(FetchMode::NUMERIC);
|
||||
|
||||
if (false === $row) {
|
||||
if ($row === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -1,30 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
/**
|
||||
* Contract for a connection that is able to provide information about the server it is connected to.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
interface ServerInfoAwareConnection
|
||||
{
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
@@ -26,11 +9,6 @@ use Doctrine\DBAL\ParameterType;
|
||||
* Drivers must implement this interface.
|
||||
*
|
||||
* This resembles (a subset of) the PDOStatement interface.
|
||||
*
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
*/
|
||||
interface Statement extends ResultStatement
|
||||
{
|
||||
@@ -92,9 +70,7 @@ interface Statement extends ResultStatement
|
||||
/**
|
||||
* Fetches extended error information associated with the last operation on the statement handle.
|
||||
*
|
||||
* @see Doctrine_Adapter_Interface::errorInfo()
|
||||
*
|
||||
* @return array The error info array.
|
||||
* @return mixed[] The error info array.
|
||||
*/
|
||||
public function errorInfo();
|
||||
|
||||
@@ -107,9 +83,8 @@ interface Statement extends ResultStatement
|
||||
* if any, of their associated parameter markers or pass an array of input-only
|
||||
* parameter values.
|
||||
*
|
||||
*
|
||||
* @param array|null $params An array of values with as many elements as there are
|
||||
* bound parameters in the SQL statement being executed.
|
||||
* @param mixed[]|null $params An array of values with as many elements as there are
|
||||
* bound parameters in the SQL statement being executed.
|
||||
*
|
||||
* @return bool TRUE on success or FALSE on failure.
|
||||
*/
|
||||
|
@@ -2,16 +2,13 @@
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
class StatementIterator implements \IteratorAggregate
|
||||
use IteratorAggregate;
|
||||
|
||||
class StatementIterator implements IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* @var Statement
|
||||
*/
|
||||
/** @var Statement */
|
||||
private $statement;
|
||||
|
||||
/**
|
||||
* @param Statement $statement
|
||||
*/
|
||||
public function __construct(Statement $statement)
|
||||
{
|
||||
$this->statement = $statement;
|
||||
@@ -22,7 +19,7 @@ class StatementIterator implements \IteratorAggregate
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
while (false !== ($result = $this->statement->fetch())) {
|
||||
while (($result = $this->statement->fetch()) !== false) {
|
||||
yield $result;
|
||||
}
|
||||
}
|
||||
|
@@ -1,25 +1,20 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
use Doctrine\Common\EventManager;
|
||||
use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver as DrizzlePDOMySQLDriver;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\DB2Driver;
|
||||
use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver;
|
||||
use Doctrine\DBAL\Driver\OCI8\Driver as OCI8Driver;
|
||||
use Doctrine\DBAL\Driver\PDOMySql\Driver as PDOMySQLDriver;
|
||||
use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOCIDriver;
|
||||
use Doctrine\DBAL\Driver\PDOPgSql\Driver as PDOPgSQLDriver;
|
||||
use Doctrine\DBAL\Driver\PDOSqlite\Driver as PDOSQLiteDriver;
|
||||
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSrvDriver;
|
||||
use Doctrine\DBAL\Driver\SQLAnywhere\Driver as SQLAnywhereDriver;
|
||||
use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver;
|
||||
use PDO;
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function array_merge;
|
||||
@@ -35,9 +30,6 @@ use function substr;
|
||||
|
||||
/**
|
||||
* Factory for creating Doctrine\DBAL\Connection instances.
|
||||
*
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @since 2.0
|
||||
*/
|
||||
final class DriverManager
|
||||
{
|
||||
@@ -47,24 +39,26 @@ final class DriverManager
|
||||
* To add your own driver use the 'driverClass' parameter to
|
||||
* {@link DriverManager::getConnection()}.
|
||||
*
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
private static $_driverMap = [
|
||||
'pdo_mysql' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
|
||||
'pdo_sqlite' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver',
|
||||
'pdo_pgsql' => 'Doctrine\DBAL\Driver\PDOPgSql\Driver',
|
||||
'pdo_oci' => 'Doctrine\DBAL\Driver\PDOOracle\Driver',
|
||||
'oci8' => 'Doctrine\DBAL\Driver\OCI8\Driver',
|
||||
'ibm_db2' => 'Doctrine\DBAL\Driver\IBMDB2\DB2Driver',
|
||||
'pdo_sqlsrv' => 'Doctrine\DBAL\Driver\PDOSqlsrv\Driver',
|
||||
'mysqli' => 'Doctrine\DBAL\Driver\Mysqli\Driver',
|
||||
'drizzle_pdo_mysql' => 'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver',
|
||||
'sqlanywhere' => 'Doctrine\DBAL\Driver\SQLAnywhere\Driver',
|
||||
'sqlsrv' => 'Doctrine\DBAL\Driver\SQLSrv\Driver',
|
||||
private static $_driverMap = [
|
||||
'pdo_mysql' => PDOMySQLDriver::class,
|
||||
'pdo_sqlite' => PDOSQLiteDriver::class,
|
||||
'pdo_pgsql' => PDOPgSQLDriver::class,
|
||||
'pdo_oci' => PDOOCIDriver::class,
|
||||
'oci8' => OCI8Driver::class,
|
||||
'ibm_db2' => DB2Driver::class,
|
||||
'pdo_sqlsrv' => PDOSQLSrvDriver::class,
|
||||
'mysqli' => MySQLiDriver::class,
|
||||
'drizzle_pdo_mysql' => DrizzlePDOMySQLDriver::class,
|
||||
'sqlanywhere' => SQLAnywhereDriver::class,
|
||||
'sqlsrv' => SQLSrvDriver::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* List of URL schemes from a database URL and their mappings to driver.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $driverSchemeAliases = [
|
||||
'db2' => 'ibm_db2',
|
||||
@@ -132,35 +126,55 @@ final class DriverManager
|
||||
* <b>driverClass</b>:
|
||||
* The driver class to use.
|
||||
*
|
||||
* @param array $params The parameters.
|
||||
* @param \Doctrine\DBAL\Configuration|null $config The configuration to use.
|
||||
* @param \Doctrine\Common\EventManager|null $eventManager The event manager to use.
|
||||
* @param mixed[] $params The parameters.
|
||||
* @param Configuration|null $config The configuration to use.
|
||||
* @param EventManager|null $eventManager The event manager to use.
|
||||
*
|
||||
* @return \Doctrine\DBAL\Connection
|
||||
*
|
||||
* @throws \Doctrine\DBAL\DBALException
|
||||
* @throws DBALException
|
||||
*/
|
||||
public static function getConnection(
|
||||
array $params,
|
||||
Configuration $config = null,
|
||||
EventManager $eventManager = null): Connection
|
||||
{
|
||||
array $params,
|
||||
?Configuration $config = null,
|
||||
?EventManager $eventManager = null
|
||||
) : Connection {
|
||||
// create default config and event manager, if not set
|
||||
if ( ! $config) {
|
||||
if (! $config) {
|
||||
$config = new Configuration();
|
||||
}
|
||||
if ( ! $eventManager) {
|
||||
if (! $eventManager) {
|
||||
$eventManager = new EventManager();
|
||||
}
|
||||
|
||||
$params = self::parseDatabaseUrl($params);
|
||||
|
||||
// URL support for MasterSlaveConnection
|
||||
if (isset($params['master'])) {
|
||||
$params['master'] = self::parseDatabaseUrl($params['master']);
|
||||
}
|
||||
|
||||
if (isset($params['slaves'])) {
|
||||
foreach ($params['slaves'] as $key => $slaveParams) {
|
||||
$params['slaves'][$key] = self::parseDatabaseUrl($slaveParams);
|
||||
}
|
||||
}
|
||||
|
||||
// URL support for PoolingShardConnection
|
||||
if (isset($params['global'])) {
|
||||
$params['global'] = self::parseDatabaseUrl($params['global']);
|
||||
}
|
||||
|
||||
if (isset($params['shards'])) {
|
||||
foreach ($params['shards'] as $key => $shardParams) {
|
||||
$params['shards'][$key] = self::parseDatabaseUrl($shardParams);
|
||||
}
|
||||
}
|
||||
|
||||
// check for existing pdo object
|
||||
if (isset($params['pdo']) && ! $params['pdo'] instanceof \PDO) {
|
||||
if (isset($params['pdo']) && ! $params['pdo'] instanceof PDO) {
|
||||
throw DBALException::invalidPdoInstance();
|
||||
} elseif (isset($params['pdo'])) {
|
||||
$params['pdo']->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
$params['driver'] = 'pdo_' . $params['pdo']->getAttribute(\PDO::ATTR_DRIVER_NAME);
|
||||
$params['pdo']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$params['driver'] = 'pdo_' . $params['pdo']->getAttribute(PDO::ATTR_DRIVER_NAME);
|
||||
} else {
|
||||
self::_checkParams($params);
|
||||
}
|
||||
@@ -169,13 +183,13 @@ final class DriverManager
|
||||
|
||||
$driver = new $className();
|
||||
|
||||
$wrapperClass = 'Doctrine\DBAL\Connection';
|
||||
$wrapperClass = Connection::class;
|
||||
if (isset($params['wrapperClass'])) {
|
||||
if (is_subclass_of($params['wrapperClass'], $wrapperClass)) {
|
||||
$wrapperClass = $params['wrapperClass'];
|
||||
} else {
|
||||
if (! is_subclass_of($params['wrapperClass'], $wrapperClass)) {
|
||||
throw DBALException::invalidWrapperClass($params['wrapperClass']);
|
||||
}
|
||||
|
||||
$wrapperClass = $params['wrapperClass'];
|
||||
}
|
||||
|
||||
return new $wrapperClass($params, $driver, $config, $eventManager);
|
||||
@@ -184,9 +198,9 @@ final class DriverManager
|
||||
/**
|
||||
* Returns the list of supported drivers.
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getAvailableDrivers(): array
|
||||
public static function getAvailableDrivers() : array
|
||||
{
|
||||
return array_keys(self::$_driverMap);
|
||||
}
|
||||
@@ -194,18 +208,16 @@ final class DriverManager
|
||||
/**
|
||||
* Checks the list of parameters.
|
||||
*
|
||||
* @param array $params The list of parameters.
|
||||
* @param mixed[] $params The list of parameters.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Doctrine\DBAL\DBALException
|
||||
* @throws DBALException
|
||||
*/
|
||||
private static function _checkParams(array $params): void
|
||||
private static function _checkParams(array $params) : void
|
||||
{
|
||||
// check existence of mandatory parameters
|
||||
|
||||
// driver
|
||||
if ( ! isset($params['driver']) && ! isset($params['driverClass'])) {
|
||||
if (! isset($params['driver']) && ! isset($params['driverClass'])) {
|
||||
throw DBALException::driverRequired();
|
||||
}
|
||||
|
||||
@@ -216,7 +228,7 @@ final class DriverManager
|
||||
throw DBALException::unknownDriver($params['driver'], array_keys(self::$_driverMap));
|
||||
}
|
||||
|
||||
if (isset($params['driverClass']) && ! in_array('Doctrine\DBAL\Driver', class_implements($params['driverClass'], true))) {
|
||||
if (isset($params['driverClass']) && ! in_array(Driver::class, class_implements($params['driverClass'], true))) {
|
||||
throw DBALException::invalidDriverClass($params['driverClass']);
|
||||
}
|
||||
}
|
||||
@@ -224,11 +236,9 @@ final class DriverManager
|
||||
/**
|
||||
* Normalizes the given connection URL path.
|
||||
*
|
||||
* @param string $urlPath
|
||||
*
|
||||
* @return string The normalized connection URL path
|
||||
*/
|
||||
private static function normalizeDatabaseUrlPath(string $urlPath): string
|
||||
private static function normalizeDatabaseUrlPath(string $urlPath) : string
|
||||
{
|
||||
// Trim leading slash from URL path.
|
||||
return substr($urlPath, 1);
|
||||
@@ -238,16 +248,16 @@ final class DriverManager
|
||||
* Extracts parts from a database URL, if present, and returns an
|
||||
* updated list of parameters.
|
||||
*
|
||||
* @param array $params The list of parameters.
|
||||
* @param mixed[] $params The list of parameters.
|
||||
*
|
||||
* @return array A modified list of parameters with info from a database
|
||||
* URL extracted into indidivual parameter parts.
|
||||
* @return mixed[] A modified list of parameters with info from a database
|
||||
* URL extracted into indidivual parameter parts.
|
||||
*
|
||||
* @throws DBALException
|
||||
*/
|
||||
private static function parseDatabaseUrl(array $params): array
|
||||
private static function parseDatabaseUrl(array $params) : array
|
||||
{
|
||||
if (!isset($params['url'])) {
|
||||
if (! isset($params['url'])) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
@@ -292,14 +302,14 @@ final class DriverManager
|
||||
* Assumes that the connection URL scheme is already parsed and resolved into the given connection parameters
|
||||
* via {@link parseDatabaseUrlScheme}.
|
||||
*
|
||||
* @param array $url The URL parts to evaluate.
|
||||
* @param array $params The connection parameters to resolve.
|
||||
*
|
||||
* @return array The resolved connection parameters.
|
||||
*
|
||||
* @see parseDatabaseUrlScheme
|
||||
*
|
||||
* @param mixed[] $url The URL parts to evaluate.
|
||||
* @param mixed[] $params The connection parameters to resolve.
|
||||
*
|
||||
* @return mixed[] The resolved connection parameters.
|
||||
*/
|
||||
private static function parseDatabaseUrlPath(array $url, array $params): array
|
||||
private static function parseDatabaseUrlPath(array $url, array $params) : array
|
||||
{
|
||||
if (! isset($url['path'])) {
|
||||
return $params;
|
||||
@@ -323,12 +333,12 @@ final class DriverManager
|
||||
/**
|
||||
* Parses the query part of the given connection URL and resolves the given connection parameters.
|
||||
*
|
||||
* @param array $url The connection URL parts to evaluate.
|
||||
* @param array $params The connection parameters to resolve.
|
||||
* @param mixed[] $url The connection URL parts to evaluate.
|
||||
* @param mixed[] $params The connection parameters to resolve.
|
||||
*
|
||||
* @return array The resolved connection parameters.
|
||||
* @return mixed[] The resolved connection parameters.
|
||||
*/
|
||||
private static function parseDatabaseUrlQuery(array $url, array $params): array
|
||||
private static function parseDatabaseUrlQuery(array $url, array $params) : array
|
||||
{
|
||||
if (! isset($url['query'])) {
|
||||
return $params;
|
||||
@@ -346,14 +356,14 @@ final class DriverManager
|
||||
*
|
||||
* Assumes that the "path" URL part is already normalized via {@link normalizeDatabaseUrlPath}.
|
||||
*
|
||||
* @param array $url The regular connection URL parts to evaluate.
|
||||
* @param array $params The connection parameters to resolve.
|
||||
*
|
||||
* @return array The resolved connection parameters.
|
||||
*
|
||||
* @see normalizeDatabaseUrlPath
|
||||
*
|
||||
* @param mixed[] $url The regular connection URL parts to evaluate.
|
||||
* @param mixed[] $params The connection parameters to resolve.
|
||||
*
|
||||
* @return mixed[] The resolved connection parameters.
|
||||
*/
|
||||
private static function parseRegularDatabaseUrlPath(array $url, array $params): array
|
||||
private static function parseRegularDatabaseUrlPath(array $url, array $params) : array
|
||||
{
|
||||
$params['dbname'] = $url['path'];
|
||||
|
||||
@@ -365,14 +375,14 @@ final class DriverManager
|
||||
*
|
||||
* Assumes that the "path" URL part is already normalized via {@link normalizeDatabaseUrlPath}.
|
||||
*
|
||||
* @param array $url The SQLite connection URL parts to evaluate.
|
||||
* @param array $params The connection parameters to resolve.
|
||||
*
|
||||
* @return array The resolved connection parameters.
|
||||
*
|
||||
* @see normalizeDatabaseUrlPath
|
||||
*
|
||||
* @param mixed[] $url The SQLite connection URL parts to evaluate.
|
||||
* @param mixed[] $params The connection parameters to resolve.
|
||||
*
|
||||
* @return mixed[] The resolved connection parameters.
|
||||
*/
|
||||
private static function parseSqliteDatabaseUrlPath(array $url, array $params): array
|
||||
private static function parseSqliteDatabaseUrlPath(array $url, array $params) : array
|
||||
{
|
||||
if ($url['path'] === ':memory:') {
|
||||
$params['memory'] = true;
|
||||
@@ -388,14 +398,14 @@ final class DriverManager
|
||||
/**
|
||||
* Parses the scheme part from given connection URL and resolves the given connection parameters.
|
||||
*
|
||||
* @param array $url The connection URL parts to evaluate.
|
||||
* @param array $params The connection parameters to resolve.
|
||||
* @param mixed[] $url The connection URL parts to evaluate.
|
||||
* @param mixed[] $params The connection parameters to resolve.
|
||||
*
|
||||
* @return array The resolved connection parameters.
|
||||
* @return mixed[] The resolved connection parameters.
|
||||
*
|
||||
* @throws DBALException if parsing failed or resolution is not possible.
|
||||
* @throws DBALException If parsing failed or resolution is not possible.
|
||||
*/
|
||||
private static function parseDatabaseUrlScheme(array $url, array $params): array
|
||||
private static function parseDatabaseUrlScheme(array $url, array $params) : array
|
||||
{
|
||||
if (isset($url['scheme'])) {
|
||||
// The requested driver from the URL scheme takes precedence
|
||||
|
@@ -1,78 +1,55 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
use Doctrine\Common\EventArgs;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
||||
|
||||
/**
|
||||
* Event Arguments used when a Driver connection is established inside Doctrine\DBAL\Connection.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class ConnectionEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Connection
|
||||
*/
|
||||
private $_connection;
|
||||
/** @var Connection */
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Connection $connection
|
||||
*/
|
||||
public function __construct(Connection $connection)
|
||||
{
|
||||
$this->_connection = $connection;
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Connection
|
||||
* @return Connection
|
||||
*/
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->_connection;
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Driver
|
||||
* @return Driver
|
||||
*/
|
||||
public function getDriver()
|
||||
{
|
||||
return $this->_connection->getDriver();
|
||||
return $this->connection->getDriver();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
* @return AbstractPlatform
|
||||
*/
|
||||
public function getDatabasePlatform()
|
||||
{
|
||||
return $this->_connection->getDatabasePlatform();
|
||||
return $this->connection->getDatabasePlatform();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\AbstractSchemaManager
|
||||
* @return AbstractSchemaManager
|
||||
*/
|
||||
public function getSchemaManager()
|
||||
{
|
||||
return $this->_connection->getSchemaManager();
|
||||
return $this->connection->getSchemaManager();
|
||||
}
|
||||
}
|
||||
|
@@ -1,34 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event\Listeners;
|
||||
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\DBAL\Event\ConnectionEventArgs;
|
||||
use Doctrine\DBAL\Events;
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
|
||||
/**
|
||||
* MySQL Session Init Event Subscriber which allows to set the Client Encoding of the Connection.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @deprecated Use "charset" option to PDO MySQL Connection instead.
|
||||
*/
|
||||
class MysqlSessionInit implements EventSubscriber
|
||||
@@ -38,36 +18,34 @@ class MysqlSessionInit implements EventSubscriber
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_charset;
|
||||
private $charset;
|
||||
|
||||
/**
|
||||
* The collation, or FALSE if no collation.
|
||||
*
|
||||
* @var string|boolean
|
||||
* @var string|bool
|
||||
*/
|
||||
private $_collation;
|
||||
private $collation;
|
||||
|
||||
/**
|
||||
* Configure Charset and Collation options of MySQL Client for each Connection.
|
||||
*
|
||||
* @param string $charset The charset.
|
||||
* @param string|boolean $collation The collation, or FALSE if no collation.
|
||||
* @param string $charset The charset.
|
||||
* @param string|bool $collation The collation, or FALSE if no collation.
|
||||
*/
|
||||
public function __construct($charset = 'utf8', $collation = false)
|
||||
{
|
||||
$this->_charset = $charset;
|
||||
$this->_collation = $collation;
|
||||
$this->charset = $charset;
|
||||
$this->collation = $collation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Event\ConnectionEventArgs $args
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postConnect(ConnectionEventArgs $args)
|
||||
{
|
||||
$collation = ($this->_collation) ? " COLLATE ".$this->_collation : "";
|
||||
$args->getConnection()->executeUpdate("SET NAMES ".$this->_charset . $collation);
|
||||
$collation = $this->collation ? ' COLLATE ' . $this->collation : '';
|
||||
$args->getConnection()->executeUpdate('SET NAMES ' . $this->charset . $collation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,27 +1,11 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event\Listeners;
|
||||
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\DBAL\Event\ConnectionEventArgs;
|
||||
use Doctrine\DBAL\Events;
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use const CASE_UPPER;
|
||||
use function array_change_key_case;
|
||||
use function array_merge;
|
||||
use function count;
|
||||
@@ -36,26 +20,20 @@ use function implode;
|
||||
* NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
|
||||
* NLS_TIMESTAMP_FORMAT="YYYY-MM-DD HH24:MI:SS"
|
||||
* NLS_TIMESTAMP_TZ_FORMAT="YYYY-MM-DD HH24:MI:SS TZH:TZM"
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class OracleSessionInit implements EventSubscriber
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
/** @var string[] */
|
||||
protected $_defaultSessionVars = [
|
||||
'NLS_TIME_FORMAT' => "HH24:MI:SS",
|
||||
'NLS_DATE_FORMAT' => "YYYY-MM-DD HH24:MI:SS",
|
||||
'NLS_TIMESTAMP_FORMAT' => "YYYY-MM-DD HH24:MI:SS",
|
||||
'NLS_TIMESTAMP_TZ_FORMAT' => "YYYY-MM-DD HH24:MI:SS TZH:TZM",
|
||||
'NLS_NUMERIC_CHARACTERS' => ".,",
|
||||
'NLS_TIME_FORMAT' => 'HH24:MI:SS',
|
||||
'NLS_DATE_FORMAT' => 'YYYY-MM-DD HH24:MI:SS',
|
||||
'NLS_TIMESTAMP_FORMAT' => 'YYYY-MM-DD HH24:MI:SS',
|
||||
'NLS_TIMESTAMP_TZ_FORMAT' => 'YYYY-MM-DD HH24:MI:SS TZH:TZM',
|
||||
'NLS_NUMERIC_CHARACTERS' => '.,',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array $oracleSessionVars
|
||||
* @param string[] $oracleSessionVars
|
||||
*/
|
||||
public function __construct(array $oracleSessionVars = [])
|
||||
{
|
||||
@@ -63,25 +41,25 @@ class OracleSessionInit implements EventSubscriber
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Event\ConnectionEventArgs $args
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postConnect(ConnectionEventArgs $args)
|
||||
{
|
||||
if (count($this->_defaultSessionVars)) {
|
||||
array_change_key_case($this->_defaultSessionVars, \CASE_UPPER);
|
||||
$vars = [];
|
||||
foreach ($this->_defaultSessionVars as $option => $value) {
|
||||
if ($option === 'CURRENT_SCHEMA') {
|
||||
$vars[] = $option . " = " . $value;
|
||||
} else {
|
||||
$vars[] = $option . " = '" . $value . "'";
|
||||
}
|
||||
}
|
||||
$sql = "ALTER SESSION SET ".implode(" ", $vars);
|
||||
$args->getConnection()->executeUpdate($sql);
|
||||
if (! count($this->_defaultSessionVars)) {
|
||||
return;
|
||||
}
|
||||
|
||||
array_change_key_case($this->_defaultSessionVars, CASE_UPPER);
|
||||
$vars = [];
|
||||
foreach ($this->_defaultSessionVars as $option => $value) {
|
||||
if ($option === 'CURRENT_SCHEMA') {
|
||||
$vars[] = $option . ' = ' . $value;
|
||||
} else {
|
||||
$vars[] = $option . " = '" . $value . "'";
|
||||
}
|
||||
}
|
||||
$sql = 'ALTER SESSION SET ' . implode(' ', $vars);
|
||||
$args->getConnection()->executeUpdate($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,40 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event\Listeners;
|
||||
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\DBAL\Event\ConnectionEventArgs;
|
||||
use Doctrine\DBAL\Events;
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
|
||||
/**
|
||||
* Session init listener for executing a single SQL statement right after a connection is opened.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class SQLSessionInit implements EventSubscriber
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $sql;
|
||||
|
||||
/**
|
||||
@@ -46,8 +23,6 @@ class SQLSessionInit implements EventSubscriber
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Event\ConnectionEventArgs $args
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postConnect(ConnectionEventArgs $args)
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
@@ -27,90 +10,73 @@ use function is_array;
|
||||
|
||||
/**
|
||||
* Event Arguments used when SQL queries for adding table columns are generated inside Doctrine\DBAL\Platform\*Platform.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\Column
|
||||
*/
|
||||
private $_column;
|
||||
/** @var Column */
|
||||
private $column;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\TableDiff
|
||||
*/
|
||||
private $_tableDiff;
|
||||
/** @var TableDiff */
|
||||
private $tableDiff;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
*/
|
||||
private $_platform;
|
||||
/** @var AbstractPlatform */
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_sql = [];
|
||||
/** @var string[] */
|
||||
private $sql = [];
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\Column $column
|
||||
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
|
||||
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
||||
*/
|
||||
public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
|
||||
{
|
||||
$this->_column = $column;
|
||||
$this->_tableDiff = $tableDiff;
|
||||
$this->_platform = $platform;
|
||||
$this->column = $column;
|
||||
$this->tableDiff = $tableDiff;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\Column
|
||||
* @return Column
|
||||
*/
|
||||
public function getColumn()
|
||||
{
|
||||
return $this->_column;
|
||||
return $this->column;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\TableDiff
|
||||
* @return TableDiff
|
||||
*/
|
||||
public function getTableDiff()
|
||||
{
|
||||
return $this->_tableDiff;
|
||||
return $this->tableDiff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
* @return AbstractPlatform
|
||||
*/
|
||||
public function getPlatform()
|
||||
{
|
||||
return $this->_platform;
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $sql
|
||||
* @param string|string[] $sql
|
||||
*
|
||||
* @return \Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
|
||||
*/
|
||||
public function addSql($sql)
|
||||
{
|
||||
if (is_array($sql)) {
|
||||
$this->_sql = array_merge($this->_sql, $sql);
|
||||
$this->sql = array_merge($this->sql, $sql);
|
||||
} else {
|
||||
$this->_sql[] = $sql;
|
||||
$this->sql[] = $sql;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSql()
|
||||
{
|
||||
return $this->_sql;
|
||||
return $this->sql;
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
@@ -27,90 +10,73 @@ use function is_array;
|
||||
|
||||
/**
|
||||
* Event Arguments used when SQL queries for changing table columns are generated inside Doctrine\DBAL\Platform\*Platform.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\ColumnDiff
|
||||
*/
|
||||
private $_columnDiff;
|
||||
/** @var ColumnDiff */
|
||||
private $columnDiff;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\TableDiff
|
||||
*/
|
||||
private $_tableDiff;
|
||||
/** @var TableDiff */
|
||||
private $tableDiff;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
*/
|
||||
private $_platform;
|
||||
/** @var AbstractPlatform */
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_sql = [];
|
||||
/** @var string[] */
|
||||
private $sql = [];
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\ColumnDiff $columnDiff
|
||||
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
|
||||
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
||||
*/
|
||||
public function __construct(ColumnDiff $columnDiff, TableDiff $tableDiff, AbstractPlatform $platform)
|
||||
{
|
||||
$this->_columnDiff = $columnDiff;
|
||||
$this->_tableDiff = $tableDiff;
|
||||
$this->_platform = $platform;
|
||||
$this->columnDiff = $columnDiff;
|
||||
$this->tableDiff = $tableDiff;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\ColumnDiff
|
||||
* @return ColumnDiff
|
||||
*/
|
||||
public function getColumnDiff()
|
||||
{
|
||||
return $this->_columnDiff;
|
||||
return $this->columnDiff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\TableDiff
|
||||
* @return TableDiff
|
||||
*/
|
||||
public function getTableDiff()
|
||||
{
|
||||
return $this->_tableDiff;
|
||||
return $this->tableDiff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
* @return AbstractPlatform
|
||||
*/
|
||||
public function getPlatform()
|
||||
{
|
||||
return $this->_platform;
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $sql
|
||||
* @param string|string[] $sql
|
||||
*
|
||||
* @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
|
||||
*/
|
||||
public function addSql($sql)
|
||||
{
|
||||
if (is_array($sql)) {
|
||||
$this->_sql = array_merge($this->_sql, $sql);
|
||||
$this->sql = array_merge($this->sql, $sql);
|
||||
} else {
|
||||
$this->_sql[] = $sql;
|
||||
$this->sql[] = $sql;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSql()
|
||||
{
|
||||
return $this->_sql;
|
||||
return $this->sql;
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
@@ -26,75 +9,61 @@ use function is_array;
|
||||
|
||||
/**
|
||||
* Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\*Platform.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
class SchemaAlterTableEventArgs extends SchemaEventArgs
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\TableDiff
|
||||
*/
|
||||
private $_tableDiff;
|
||||
/** @var TableDiff */
|
||||
private $tableDiff;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
*/
|
||||
private $_platform;
|
||||
/** @var AbstractPlatform */
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_sql = [];
|
||||
/** @var string[] */
|
||||
private $sql = [];
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
|
||||
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
||||
*/
|
||||
public function __construct(TableDiff $tableDiff, AbstractPlatform $platform)
|
||||
{
|
||||
$this->_tableDiff = $tableDiff;
|
||||
$this->_platform = $platform;
|
||||
$this->tableDiff = $tableDiff;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\TableDiff
|
||||
* @return TableDiff
|
||||
*/
|
||||
public function getTableDiff()
|
||||
{
|
||||
return $this->_tableDiff;
|
||||
return $this->tableDiff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
* @return AbstractPlatform
|
||||
*/
|
||||
public function getPlatform()
|
||||
{
|
||||
return $this->_platform;
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $sql
|
||||
* @param string|string[] $sql
|
||||
*
|
||||
* @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs
|
||||
*/
|
||||
public function addSql($sql)
|
||||
{
|
||||
if (is_array($sql)) {
|
||||
$this->_sql = array_merge($this->_sql, $sql);
|
||||
$this->sql = array_merge($this->sql, $sql);
|
||||
} else {
|
||||
$this->_sql[] = $sql;
|
||||
$this->sql[] = $sql;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSql()
|
||||
{
|
||||
return $this->_sql;
|
||||
return $this->sql;
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
@@ -27,90 +10,73 @@ use function is_array;
|
||||
|
||||
/**
|
||||
* Event Arguments used when SQL queries for removing table columns are generated inside Doctrine\DBAL\Platform\*Platform.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\Column
|
||||
*/
|
||||
private $_column;
|
||||
/** @var Column */
|
||||
private $column;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\TableDiff
|
||||
*/
|
||||
private $_tableDiff;
|
||||
/** @var TableDiff */
|
||||
private $tableDiff;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
*/
|
||||
private $_platform;
|
||||
/** @var AbstractPlatform */
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_sql = [];
|
||||
/** @var string[] */
|
||||
private $sql = [];
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\Column $column
|
||||
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
|
||||
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
||||
*/
|
||||
public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
|
||||
{
|
||||
$this->_column = $column;
|
||||
$this->_tableDiff = $tableDiff;
|
||||
$this->_platform = $platform;
|
||||
$this->column = $column;
|
||||
$this->tableDiff = $tableDiff;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\Column
|
||||
* @return Column
|
||||
*/
|
||||
public function getColumn()
|
||||
{
|
||||
return $this->_column;
|
||||
return $this->column;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\TableDiff
|
||||
* @return TableDiff
|
||||
*/
|
||||
public function getTableDiff()
|
||||
{
|
||||
return $this->_tableDiff;
|
||||
return $this->tableDiff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
* @return AbstractPlatform
|
||||
*/
|
||||
public function getPlatform()
|
||||
{
|
||||
return $this->_platform;
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $sql
|
||||
* @param string|string[] $sql
|
||||
*
|
||||
* @return \Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs
|
||||
*/
|
||||
public function addSql($sql)
|
||||
{
|
||||
if (is_array($sql)) {
|
||||
$this->_sql = array_merge($this->_sql, $sql);
|
||||
$this->sql = array_merge($this->sql, $sql);
|
||||
} else {
|
||||
$this->_sql[] = $sql;
|
||||
$this->sql[] = $sql;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSql()
|
||||
{
|
||||
return $this->_sql;
|
||||
return $this->sql;
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
@@ -27,50 +10,33 @@ use function is_array;
|
||||
|
||||
/**
|
||||
* Event Arguments used when SQL queries for renaming table columns are generated inside Doctrine\DBAL\Platform\*Platform.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_oldColumnName;
|
||||
/** @var string */
|
||||
private $oldColumnName;
|
||||
|
||||
/** @var Column */
|
||||
private $column;
|
||||
|
||||
/** @var TableDiff */
|
||||
private $tableDiff;
|
||||
|
||||
/** @var AbstractPlatform */
|
||||
private $platform;
|
||||
|
||||
/** @var string[] */
|
||||
private $sql = [];
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\Column
|
||||
*/
|
||||
private $_column;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\TableDiff
|
||||
*/
|
||||
private $_tableDiff;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
*/
|
||||
private $_platform;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_sql = [];
|
||||
|
||||
/**
|
||||
* @param string $oldColumnName
|
||||
* @param \Doctrine\DBAL\Schema\Column $column
|
||||
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
|
||||
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
||||
* @param string $oldColumnName
|
||||
*/
|
||||
public function __construct($oldColumnName, Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
|
||||
{
|
||||
$this->_oldColumnName = $oldColumnName;
|
||||
$this->_column = $column;
|
||||
$this->_tableDiff = $tableDiff;
|
||||
$this->_platform = $platform;
|
||||
$this->oldColumnName = $oldColumnName;
|
||||
$this->column = $column;
|
||||
$this->tableDiff = $tableDiff;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,54 +44,54 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
|
||||
*/
|
||||
public function getOldColumnName()
|
||||
{
|
||||
return $this->_oldColumnName;
|
||||
return $this->oldColumnName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\Column
|
||||
* @return Column
|
||||
*/
|
||||
public function getColumn()
|
||||
{
|
||||
return $this->_column;
|
||||
return $this->column;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\TableDiff
|
||||
* @return TableDiff
|
||||
*/
|
||||
public function getTableDiff()
|
||||
{
|
||||
return $this->_tableDiff;
|
||||
return $this->tableDiff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
* @return AbstractPlatform
|
||||
*/
|
||||
public function getPlatform()
|
||||
{
|
||||
return $this->_platform;
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $sql
|
||||
* @param string|string[] $sql
|
||||
*
|
||||
* @return \Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs
|
||||
*/
|
||||
public function addSql($sql)
|
||||
{
|
||||
if (is_array($sql)) {
|
||||
$this->_sql = array_merge($this->_sql, $sql);
|
||||
$this->sql = array_merge($this->sql, $sql);
|
||||
} else {
|
||||
$this->_sql[] = $sql;
|
||||
$this->sql[] = $sql;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSql()
|
||||
{
|
||||
return $this->_sql;
|
||||
return $this->sql;
|
||||
}
|
||||
}
|
||||
|
@@ -1,106 +1,75 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Schema\Column;
|
||||
|
||||
/**
|
||||
* Event Arguments used when the portable column definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\Column|null
|
||||
*/
|
||||
private $_column = null;
|
||||
/** @var Column|null */
|
||||
private $column = null;
|
||||
|
||||
/**
|
||||
* Raw column data as fetched from the database.
|
||||
*
|
||||
* @var array
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $_tableColumn;
|
||||
private $tableColumn;
|
||||
|
||||
/** @var string */
|
||||
private $table;
|
||||
|
||||
/** @var string */
|
||||
private $database;
|
||||
|
||||
/** @var Connection */
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_table;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_database;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Connection
|
||||
*/
|
||||
private $_connection;
|
||||
|
||||
/**
|
||||
* @param array $tableColumn
|
||||
* @param string $table
|
||||
* @param string $database
|
||||
* @param \Doctrine\DBAL\Connection $connection
|
||||
* @param mixed[] $tableColumn
|
||||
* @param string $table
|
||||
* @param string $database
|
||||
*/
|
||||
public function __construct(array $tableColumn, $table, $database, Connection $connection)
|
||||
{
|
||||
$this->_tableColumn = $tableColumn;
|
||||
$this->_table = $table;
|
||||
$this->_database = $database;
|
||||
$this->_connection = $connection;
|
||||
$this->tableColumn = $tableColumn;
|
||||
$this->table = $table;
|
||||
$this->database = $database;
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to clear the column which means the column will be excluded from
|
||||
* tables column list.
|
||||
*
|
||||
* @param null|\Doctrine\DBAL\Schema\Column $column
|
||||
*
|
||||
* @return \Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs
|
||||
*/
|
||||
public function setColumn(Column $column = null)
|
||||
public function setColumn(?Column $column = null)
|
||||
{
|
||||
$this->_column = $column;
|
||||
$this->column = $column;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\Column|null
|
||||
* @return Column|null
|
||||
*/
|
||||
public function getColumn()
|
||||
{
|
||||
return $this->_column;
|
||||
return $this->column;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getTableColumn()
|
||||
{
|
||||
return $this->_tableColumn;
|
||||
return $this->tableColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +77,7 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
|
||||
*/
|
||||
public function getTable()
|
||||
{
|
||||
return $this->_table;
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,22 +85,22 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
|
||||
*/
|
||||
public function getDatabase()
|
||||
{
|
||||
return $this->_database;
|
||||
return $this->database;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Connection
|
||||
* @return Connection
|
||||
*/
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->_connection;
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
* @return AbstractPlatform
|
||||
*/
|
||||
public function getDatabasePlatform()
|
||||
{
|
||||
return $this->_connection->getDatabasePlatform();
|
||||
return $this->connection->getDatabasePlatform();
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
@@ -27,90 +10,73 @@ use function is_array;
|
||||
|
||||
/**
|
||||
* Event Arguments used when SQL queries for creating table columns are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\Column
|
||||
*/
|
||||
private $_column;
|
||||
/** @var Column */
|
||||
private $column;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\Table
|
||||
*/
|
||||
private $_table;
|
||||
/** @var Table */
|
||||
private $table;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
*/
|
||||
private $_platform;
|
||||
/** @var AbstractPlatform */
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_sql = [];
|
||||
/** @var string[] */
|
||||
private $sql = [];
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\Column $column
|
||||
* @param \Doctrine\DBAL\Schema\Table $table
|
||||
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
||||
*/
|
||||
public function __construct(Column $column, Table $table, AbstractPlatform $platform)
|
||||
{
|
||||
$this->_column = $column;
|
||||
$this->_table = $table;
|
||||
$this->_platform = $platform;
|
||||
$this->column = $column;
|
||||
$this->table = $table;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\Column
|
||||
* @return Column
|
||||
*/
|
||||
public function getColumn()
|
||||
{
|
||||
return $this->_column;
|
||||
return $this->column;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\Table
|
||||
* @return Table
|
||||
*/
|
||||
public function getTable()
|
||||
{
|
||||
return $this->_table;
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
* @return AbstractPlatform
|
||||
*/
|
||||
public function getPlatform()
|
||||
{
|
||||
return $this->_platform;
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $sql
|
||||
* @param string|string[] $sql
|
||||
*
|
||||
* @return \Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs
|
||||
*/
|
||||
public function addSql($sql)
|
||||
{
|
||||
if (is_array($sql)) {
|
||||
$this->_sql = array_merge($this->_sql, $sql);
|
||||
$this->sql = array_merge($this->sql, $sql);
|
||||
} else {
|
||||
$this->_sql[] = $sql;
|
||||
$this->sql[] = $sql;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSql()
|
||||
{
|
||||
return $this->_sql;
|
||||
return $this->sql;
|
||||
}
|
||||
}
|
||||
|
@@ -1,130 +1,98 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Schema\Column;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
use function array_merge;
|
||||
use function is_array;
|
||||
|
||||
/**
|
||||
* Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
class SchemaCreateTableEventArgs extends SchemaEventArgs
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\Table
|
||||
*/
|
||||
private $_table;
|
||||
/** @var Table */
|
||||
private $table;
|
||||
|
||||
/** @var Column[] */
|
||||
private $columns;
|
||||
|
||||
/** @var mixed[] */
|
||||
private $options;
|
||||
|
||||
/** @var AbstractPlatform */
|
||||
private $platform;
|
||||
|
||||
/** @var string[] */
|
||||
private $sql = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_columns;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_options;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
*/
|
||||
private $_platform;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_sql = [];
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\Table $table
|
||||
* @param array $columns
|
||||
* @param array $options
|
||||
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
||||
* @param Column[] $columns
|
||||
* @param mixed[] $options
|
||||
*/
|
||||
public function __construct(Table $table, array $columns, array $options, AbstractPlatform $platform)
|
||||
{
|
||||
$this->_table = $table;
|
||||
$this->_columns = $columns;
|
||||
$this->_options = $options;
|
||||
$this->_platform = $platform;
|
||||
$this->table = $table;
|
||||
$this->columns = $columns;
|
||||
$this->options = $options;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\Table
|
||||
* @return Table
|
||||
*/
|
||||
public function getTable()
|
||||
{
|
||||
return $this->_table;
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return Column[]
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
return $this->_columns;
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->_options;
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
* @return AbstractPlatform
|
||||
*/
|
||||
public function getPlatform()
|
||||
{
|
||||
return $this->_platform;
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $sql
|
||||
* @param string|string[] $sql
|
||||
*
|
||||
* @return \Doctrine\DBAL\Event\SchemaCreateTableEventArgs
|
||||
*/
|
||||
public function addSql($sql)
|
||||
{
|
||||
if (is_array($sql)) {
|
||||
$this->_sql = array_merge($this->_sql, $sql);
|
||||
$this->sql = array_merge($this->sql, $sql);
|
||||
} else {
|
||||
$this->_sql[] = $sql;
|
||||
$this->sql[] = $sql;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSql()
|
||||
{
|
||||
return $this->_sql;
|
||||
return $this->sql;
|
||||
}
|
||||
}
|
||||
|
@@ -1,82 +1,55 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
use InvalidArgumentException;
|
||||
use function is_string;
|
||||
|
||||
/**
|
||||
* Event Arguments used when the SQL query for dropping tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
class SchemaDropTableEventArgs extends SchemaEventArgs
|
||||
{
|
||||
/**
|
||||
* @var string|\Doctrine\DBAL\Schema\Table
|
||||
*/
|
||||
private $_table;
|
||||
/** @var string|Table */
|
||||
private $table;
|
||||
|
||||
/** @var AbstractPlatform */
|
||||
private $platform;
|
||||
|
||||
/** @var string|null */
|
||||
private $sql = null;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
*/
|
||||
private $_platform;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $_sql = null;
|
||||
|
||||
/**
|
||||
* @param string|\Doctrine\DBAL\Schema\Table $table
|
||||
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
||||
* @param string|Table $table
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct($table, AbstractPlatform $platform)
|
||||
{
|
||||
if ( ! $table instanceof Table && !is_string($table)) {
|
||||
throw new \InvalidArgumentException('SchemaDropTableEventArgs expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
|
||||
if (! $table instanceof Table && ! is_string($table)) {
|
||||
throw new InvalidArgumentException('SchemaDropTableEventArgs expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
|
||||
}
|
||||
|
||||
$this->_table = $table;
|
||||
$this->_platform = $platform;
|
||||
$this->table = $table;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|\Doctrine\DBAL\Schema\Table
|
||||
* @return string|Table
|
||||
*/
|
||||
public function getTable()
|
||||
{
|
||||
return $this->_table;
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
* @return AbstractPlatform
|
||||
*/
|
||||
public function getPlatform()
|
||||
{
|
||||
return $this->_platform;
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +59,7 @@ class SchemaDropTableEventArgs extends SchemaEventArgs
|
||||
*/
|
||||
public function setSql($sql)
|
||||
{
|
||||
$this->_sql = $sql;
|
||||
$this->sql = $sql;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -96,6 +69,6 @@ class SchemaDropTableEventArgs extends SchemaEventArgs
|
||||
*/
|
||||
public function getSql()
|
||||
{
|
||||
return $this->_sql;
|
||||
return $this->sql;
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
@@ -23,24 +6,18 @@ use Doctrine\Common\EventArgs;
|
||||
|
||||
/**
|
||||
* Base class for schema related events.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
class SchemaEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $_preventDefault = false;
|
||||
/** @var bool */
|
||||
private $preventDefault = false;
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Event\SchemaEventArgs
|
||||
*/
|
||||
public function preventDefault()
|
||||
{
|
||||
$this->_preventDefault = true;
|
||||
$this->preventDefault = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -50,6 +27,6 @@ class SchemaEventArgs extends EventArgs
|
||||
*/
|
||||
public function isDefaultPrevented()
|
||||
{
|
||||
return $this->_preventDefault;
|
||||
return $this->preventDefault;
|
||||
}
|
||||
}
|
||||
|
@@ -1,98 +1,69 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Event;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Schema\Index;
|
||||
|
||||
/**
|
||||
* Event Arguments used when the portable index definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Jan Sorgalla <jsorgalla@googlemail.com>
|
||||
*/
|
||||
class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Schema\Index|null
|
||||
*/
|
||||
private $_index = null;
|
||||
/** @var Index|null */
|
||||
private $index = null;
|
||||
|
||||
/**
|
||||
* Raw index data as fetched from the database.
|
||||
*
|
||||
* @var array
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $_tableIndex;
|
||||
private $tableIndex;
|
||||
|
||||
/** @var string */
|
||||
private $table;
|
||||
|
||||
/** @var Connection */
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_table;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\DBAL\Connection
|
||||
*/
|
||||
private $_connection;
|
||||
|
||||
/**
|
||||
* @param array $tableIndex
|
||||
* @param string $table
|
||||
* @param \Doctrine\DBAL\Connection $connection
|
||||
* @param mixed[] $tableIndex
|
||||
* @param string $table
|
||||
*/
|
||||
public function __construct(array $tableIndex, $table, Connection $connection)
|
||||
{
|
||||
$this->_tableIndex = $tableIndex;
|
||||
$this->_table = $table;
|
||||
$this->_connection = $connection;
|
||||
$this->tableIndex = $tableIndex;
|
||||
$this->table = $table;
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to clear the index which means the index will be excluded from tables index list.
|
||||
*
|
||||
* @param null|\Doctrine\DBAL\Schema\Index $index
|
||||
*
|
||||
* @return SchemaIndexDefinitionEventArgs
|
||||
*/
|
||||
public function setIndex(Index $index = null)
|
||||
public function setIndex(?Index $index = null)
|
||||
{
|
||||
$this->_index = $index;
|
||||
$this->index = $index;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Schema\Index|null
|
||||
* @return Index|null
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
return $this->_index;
|
||||
return $this->index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getTableIndex()
|
||||
{
|
||||
return $this->_tableIndex;
|
||||
return $this->tableIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,22 +71,22 @@ class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
|
||||
*/
|
||||
public function getTable()
|
||||
{
|
||||
return $this->_table;
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Connection
|
||||
* @return Connection
|
||||
*/
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->_connection;
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\DBAL\Platforms\AbstractPlatform
|
||||
* @return AbstractPlatform
|
||||
*/
|
||||
public function getDatabasePlatform()
|
||||
{
|
||||
return $this->_connection->getDatabasePlatform();
|
||||
return $this->connection->getDatabasePlatform();
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
@@ -23,9 +6,6 @@ namespace Doctrine\DBAL;
|
||||
* Container for all DBAL events.
|
||||
*
|
||||
* This class cannot be instantiated.
|
||||
*
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @since 2.0
|
||||
*/
|
||||
final class Events
|
||||
{
|
||||
@@ -36,16 +16,16 @@ final class Events
|
||||
{
|
||||
}
|
||||
|
||||
const postConnect = 'postConnect';
|
||||
public const postConnect = 'postConnect';
|
||||
|
||||
const onSchemaCreateTable = 'onSchemaCreateTable';
|
||||
const onSchemaCreateTableColumn = 'onSchemaCreateTableColumn';
|
||||
const onSchemaDropTable = 'onSchemaDropTable';
|
||||
const onSchemaAlterTable = 'onSchemaAlterTable';
|
||||
const onSchemaAlterTableAddColumn = 'onSchemaAlterTableAddColumn';
|
||||
const onSchemaAlterTableRemoveColumn = 'onSchemaAlterTableRemoveColumn';
|
||||
const onSchemaAlterTableChangeColumn = 'onSchemaAlterTableChangeColumn';
|
||||
const onSchemaAlterTableRenameColumn = 'onSchemaAlterTableRenameColumn';
|
||||
const onSchemaColumnDefinition = 'onSchemaColumnDefinition';
|
||||
const onSchemaIndexDefinition = 'onSchemaIndexDefinition';
|
||||
public const onSchemaCreateTable = 'onSchemaCreateTable';
|
||||
public const onSchemaCreateTableColumn = 'onSchemaCreateTableColumn';
|
||||
public const onSchemaDropTable = 'onSchemaDropTable';
|
||||
public const onSchemaAlterTable = 'onSchemaAlterTable';
|
||||
public const onSchemaAlterTableAddColumn = 'onSchemaAlterTableAddColumn';
|
||||
public const onSchemaAlterTableRemoveColumn = 'onSchemaAlterTableRemoveColumn';
|
||||
public const onSchemaAlterTableChangeColumn = 'onSchemaAlterTableChangeColumn';
|
||||
public const onSchemaAlterTableRenameColumn = 'onSchemaAlterTableRenameColumn';
|
||||
public const onSchemaColumnDefinition = 'onSchemaColumnDefinition';
|
||||
public const onSchemaIndexDefinition = 'onSchemaIndexDefinition';
|
||||
}
|
||||
|
@@ -1,30 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Exception;
|
||||
|
||||
/**
|
||||
* Base class for all connection related errors detected in the driver.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class ConnectionException extends DriverException
|
||||
{
|
||||
|
@@ -1,30 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Exception;
|
||||
|
||||
/**
|
||||
* Base class for all constraint violation related errors detected in the driver.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class ConstraintViolationException extends ServerException
|
||||
{
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Exception;
|
||||
|
||||
@@ -25,10 +8,6 @@ namespace Doctrine\DBAL\Exception;
|
||||
* A database object is considered any asset that can be created in a database
|
||||
* such as schemas, tables, views, sequences, triggers, constraints, indexes,
|
||||
* functions, stored procedures etc.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class DatabaseObjectExistsException extends ServerException
|
||||
{
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Exception;
|
||||
|
||||
@@ -25,10 +8,6 @@ namespace Doctrine\DBAL\Exception;
|
||||
* A database object is considered any asset that can be created in a database
|
||||
* such as schemas, tables, views, sequences, triggers, constraints, indexes,
|
||||
* functions, stored procedures etc.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class DatabaseObjectNotFoundException extends ServerException
|
||||
{
|
||||
|
@@ -1,30 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Exception;
|
||||
|
||||
/**
|
||||
* Exception for a deadlock error of a transaction detected in the driver.
|
||||
*
|
||||
* @author Tobias Schultze <http://tobion.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.6
|
||||
*/
|
||||
class DeadlockException extends ServerException implements RetryableException
|
||||
{
|
||||
|
@@ -1,32 +1,12 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Exception;
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Base class for all errors detected in the driver.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class DriverException extends DBALException
|
||||
{
|
||||
@@ -38,8 +18,6 @@ class DriverException extends DBALException
|
||||
private $driverException;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message The exception message.
|
||||
* @param \Doctrine\DBAL\Driver\DriverException $driverException The DBAL driver exception to chain.
|
||||
*/
|
||||
@@ -47,7 +25,7 @@ class DriverException extends DBALException
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
if ($driverException instanceof \Exception) {
|
||||
if ($driverException instanceof Exception) {
|
||||
$exception = $driverException;
|
||||
}
|
||||
|
||||
|
@@ -1,31 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Exception;
|
||||
|
||||
/**
|
||||
* Exception for a foreign key constraint violation detected in the driver.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class ForeignKeyConstraintViolationException extends ConstraintViolationException
|
||||
{
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Exception;
|
||||
|
||||
@@ -23,10 +6,6 @@ use Doctrine\DBAL\DBALException;
|
||||
|
||||
/**
|
||||
* Exception to be thrown when invalid arguments are passed to any DBAL API
|
||||
*
|
||||
* @author Marco Pivetta <ocramius@gmail.com>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class InvalidArgumentException extends DBALException
|
||||
{
|
||||
|
@@ -1,30 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Exception;
|
||||
|
||||
/**
|
||||
* Exception for an invalid specified field name in a statement detected in the driver.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class InvalidFieldNameException extends ServerException
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user