-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
212 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
{"name": "Jonathan Wage", "email": "[email protected]"} | ||
], | ||
"require": { | ||
"php": "^7.3", | ||
"php": "^7.3 || ^8", | ||
"ext-pdo": "*", | ||
"doctrine/cache": "^1.0", | ||
"doctrine/event-manager": "^1.0" | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Driver; | ||
|
||
use Doctrine\DBAL\Driver\PDO\Exception; | ||
use PDOException; | ||
use PDOStatement; | ||
|
||
use const PHP_VERSION_ID; | ||
|
||
use function assert; | ||
use function func_get_args; | ||
|
||
if (PHP_VERSION_ID >= 80000) { | ||
/** | ||
* @internal | ||
*/ | ||
trait PDOConnectionTrait | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return PDOStatement | ||
*/ | ||
public function query(?string $query = null, ?int $fetchMode = null, mixed ...$fetchModeArgs) | ||
{ | ||
try { | ||
$stmt = parent::query($query, $fetchMode, ...$fetchModeArgs); | ||
assert($stmt instanceof PDOStatement); | ||
|
||
return $stmt; | ||
} catch (PDOException $exception) { | ||
throw Exception::new($exception); | ||
} | ||
} | ||
} | ||
} else { | ||
/** | ||
* @internal | ||
*/ | ||
trait PDOConnectionTrait | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return PDOStatement | ||
*/ | ||
public function query() | ||
{ | ||
$args = func_get_args(); | ||
|
||
try { | ||
$stmt = parent::query(...$args); | ||
assert($stmt instanceof PDOStatement); | ||
|
||
return $stmt; | ||
} catch (PDOException $exception) { | ||
throw Exception::new($exception); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Driver; | ||
|
||
use Doctrine\DBAL\Driver\PDO\Exception; | ||
use PDOException; | ||
|
||
use const PHP_VERSION_ID; | ||
|
||
use function assert; | ||
use function func_get_args; | ||
use function is_array; | ||
|
||
if (PHP_VERSION_ID >= 80000) { | ||
/** | ||
* @internal | ||
*/ | ||
trait PDOStatementTrait | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @deprecated Use one of the fetch- or iterate-related methods. | ||
*/ | ||
public function setFetchMode($mode, ...$args) | ||
{ | ||
$mode = $this->convertFetchMode($mode); | ||
|
||
$filteredArgs = array_filter($args, static function (mixed $value): bool { | ||
return $value !== null; | ||
}); | ||
if (empty($filteredArgs)) { | ||
$args = []; | ||
} | ||
|
||
try { | ||
return parent::setFetchMode($mode, ...$args); | ||
} catch (PDOException $exception) { | ||
throw Exception::new($exception); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. | ||
*/ | ||
public function fetchAll($mode = null, ...$args) | ||
{ | ||
if (null !== $mode) { | ||
$mode = $this->convertFetchMode($mode); | ||
} | ||
|
||
$filteredArgs = array_filter($args, static function (mixed $value): bool { | ||
return $value !== null; | ||
}); | ||
if (empty($filteredArgs)) { | ||
$args = []; | ||
} | ||
|
||
try { | ||
$data = parent::fetchAll($mode, ...$args); | ||
assert(is_array($data)); | ||
|
||
return $data; | ||
} catch (PDOException $exception) { | ||
throw Exception::new($exception); | ||
} | ||
} | ||
} | ||
} else { | ||
/** | ||
* @internal | ||
*/ | ||
trait PDOStatementTrait | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @deprecated Use one of the fetch- or iterate-related methods. | ||
*/ | ||
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) | ||
{ | ||
$fetchMode = $this->convertFetchMode($fetchMode); | ||
|
||
// This thin wrapper is necessary to shield against the weird signature | ||
// of PDOStatement::setFetchMode(): even if the second and third | ||
// parameters are optional, PHP will not let us remove it from this | ||
// declaration. | ||
try { | ||
if ($arg2 === null && $arg3 === null) { | ||
return parent::setFetchMode($fetchMode); | ||
} | ||
|
||
if ($arg3 === null) { | ||
return parent::setFetchMode($fetchMode, $arg2); | ||
} | ||
|
||
return parent::setFetchMode($fetchMode, $arg2, $arg3); | ||
} catch (PDOException $exception) { | ||
throw Exception::new($exception); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. | ||
*/ | ||
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) | ||
{ | ||
$args = func_get_args(); | ||
|
||
if (isset($args[0])) { | ||
$args[0] = $this->convertFetchMode($args[0]); | ||
} | ||
|
||
if ($fetchMode === null && $fetchArgument === null && $ctorArgs === null) { | ||
$args = []; | ||
} elseif ($fetchArgument === null && $ctorArgs === null) { | ||
$args = [$fetchMode]; | ||
} elseif ($ctorArgs === null) { | ||
$args = [$fetchMode, $fetchArgument]; | ||
} else { | ||
$args = [$fetchMode, $fetchArgument, $ctorArgs]; | ||
} | ||
|
||
try { | ||
$data = parent::fetchAll(...$args); | ||
assert(is_array($data)); | ||
|
||
return $data; | ||
} catch (PDOException $exception) { | ||
throw Exception::new($exception); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters