updated-packages
This commit is contained in:
7
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Connection.php
vendored
Normal file
7
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Connection.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
final class Connection extends DB2Connection
|
||||
{
|
||||
}
|
||||
@@ -2,12 +2,16 @@
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
use Doctrine\DBAL\Driver\Connection;
|
||||
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionError;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionFailed;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\PrepareFailed;
|
||||
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use stdClass;
|
||||
use const DB2_AUTOCOMMIT_OFF;
|
||||
use const DB2_AUTOCOMMIT_ON;
|
||||
|
||||
use function assert;
|
||||
use function db2_autocommit;
|
||||
use function db2_commit;
|
||||
use function db2_conn_error;
|
||||
@@ -21,15 +25,24 @@ use function db2_pconnect;
|
||||
use function db2_prepare;
|
||||
use function db2_rollback;
|
||||
use function db2_server_info;
|
||||
use function db2_stmt_errormsg;
|
||||
use function error_get_last;
|
||||
use function func_get_args;
|
||||
use function is_bool;
|
||||
|
||||
class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
use const DB2_AUTOCOMMIT_OFF;
|
||||
use const DB2_AUTOCOMMIT_ON;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Connection} instead
|
||||
*/
|
||||
class DB2Connection implements ConnectionInterface, ServerInfoAwareConnection
|
||||
{
|
||||
/** @var resource */
|
||||
private $conn = null;
|
||||
private $conn;
|
||||
|
||||
/**
|
||||
* @internal The connection can be only instantiated by its driver.
|
||||
*
|
||||
* @param mixed[] $params
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
@@ -42,13 +55,16 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
$isPersistent = (isset($params['persistent']) && $params['persistent'] === true);
|
||||
|
||||
if ($isPersistent) {
|
||||
$this->conn = db2_pconnect($params['dbname'], $username, $password, $driverOptions);
|
||||
$conn = db2_pconnect($params['dbname'], $username, $password, $driverOptions);
|
||||
} else {
|
||||
$this->conn = db2_connect($params['dbname'], $username, $password, $driverOptions);
|
||||
$conn = db2_connect($params['dbname'], $username, $password, $driverOptions);
|
||||
}
|
||||
if (! $this->conn) {
|
||||
throw new DB2Exception(db2_conn_errormsg());
|
||||
|
||||
if ($conn === false) {
|
||||
throw ConnectionFailed::new();
|
||||
}
|
||||
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,8 +72,8 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function getServerVersion()
|
||||
{
|
||||
/** @var stdClass $serverInfo */
|
||||
$serverInfo = db2_server_info($this->conn);
|
||||
assert($serverInfo instanceof stdClass);
|
||||
|
||||
return $serverInfo->DBMS_VER;
|
||||
}
|
||||
@@ -67,6 +83,12 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function requiresQueryForServerVersion()
|
||||
{
|
||||
Deprecation::triggerIfCalledFromOutside(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/4114',
|
||||
'ServerInfoAwareConnection::requiresQueryForServerVersion() is deprecated and removed in DBAL 3.'
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -76,11 +98,12 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
public function prepare($sql)
|
||||
{
|
||||
$stmt = @db2_prepare($this->conn, $sql);
|
||||
if (! $stmt) {
|
||||
throw new DB2Exception(db2_stmt_errormsg());
|
||||
|
||||
if ($stmt === false) {
|
||||
throw PrepareFailed::new(error_get_last());
|
||||
}
|
||||
|
||||
return new DB2Statement($stmt);
|
||||
return new Statement($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,26 +122,26 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function quote($input, $type = ParameterType::STRING)
|
||||
public function quote($value, $type = ParameterType::STRING)
|
||||
{
|
||||
$input = db2_escape_string($input);
|
||||
$value = db2_escape_string($value);
|
||||
|
||||
if ($type === ParameterType::INTEGER) {
|
||||
return $input;
|
||||
return $value;
|
||||
}
|
||||
|
||||
return "'" . $input . "'";
|
||||
return "'" . $value . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exec($statement)
|
||||
public function exec($sql)
|
||||
{
|
||||
$stmt = @db2_exec($this->conn, $statement);
|
||||
$stmt = @db2_exec($this->conn, $sql);
|
||||
|
||||
if ($stmt === false) {
|
||||
throw new DB2Exception(db2_stmt_errormsg());
|
||||
throw ConnectionError::new($this->conn);
|
||||
}
|
||||
|
||||
return db2_num_rows($stmt);
|
||||
@@ -137,7 +160,10 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
db2_autocommit($this->conn, DB2_AUTOCOMMIT_OFF);
|
||||
$result = db2_autocommit($this->conn, DB2_AUTOCOMMIT_OFF);
|
||||
assert(is_bool($result));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,9 +172,13 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
public function commit()
|
||||
{
|
||||
if (! db2_commit($this->conn)) {
|
||||
throw new DB2Exception(db2_conn_errormsg($this->conn));
|
||||
throw ConnectionError::new($this->conn);
|
||||
}
|
||||
db2_autocommit($this->conn, DB2_AUTOCOMMIT_ON);
|
||||
|
||||
$result = db2_autocommit($this->conn, DB2_AUTOCOMMIT_ON);
|
||||
assert(is_bool($result));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,13 +187,19 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
public function rollBack()
|
||||
{
|
||||
if (! db2_rollback($this->conn)) {
|
||||
throw new DB2Exception(db2_conn_errormsg($this->conn));
|
||||
throw ConnectionError::new($this->conn);
|
||||
}
|
||||
db2_autocommit($this->conn, DB2_AUTOCOMMIT_ON);
|
||||
|
||||
$result = db2_autocommit($this->conn, DB2_AUTOCOMMIT_ON);
|
||||
assert(is_bool($result));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated The error information is available via exceptions.
|
||||
*/
|
||||
public function errorCode()
|
||||
{
|
||||
@@ -172,6 +208,8 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated The error information is available via exceptions.
|
||||
*/
|
||||
public function errorInfo()
|
||||
{
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractDB2Driver;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
|
||||
/**
|
||||
* IBM DB2 Driver.
|
||||
*
|
||||
* @deprecated Use {@link Driver} instead
|
||||
*/
|
||||
class DB2Driver extends AbstractDB2Driver
|
||||
{
|
||||
@@ -14,34 +17,31 @@ class DB2Driver extends AbstractDB2Driver
|
||||
*/
|
||||
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
|
||||
{
|
||||
if (! isset($params['protocol'])) {
|
||||
$params['protocol'] = 'TCPIP';
|
||||
}
|
||||
$params['user'] = $username;
|
||||
$params['password'] = $password;
|
||||
$params['dbname'] = DataSourceName::fromConnectionParameters($params)->toString();
|
||||
|
||||
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 . ';';
|
||||
if (isset($params['port'])) {
|
||||
$params['dbname'] .= 'PORT=' . $params['port'];
|
||||
}
|
||||
|
||||
$username = null;
|
||||
$password = null;
|
||||
}
|
||||
|
||||
return new DB2Connection($params, $username, $password, $driverOptions);
|
||||
return new Connection(
|
||||
$params,
|
||||
(string) $username,
|
||||
(string) $password,
|
||||
$driverOptions
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/issues/3580',
|
||||
'Driver::getName() is deprecated'
|
||||
);
|
||||
|
||||
return 'ibm_db2';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
use Exception;
|
||||
use Doctrine\DBAL\Driver\AbstractDriverException;
|
||||
|
||||
class DB2Exception extends Exception
|
||||
/**
|
||||
* @deprecated Use {@link \Doctrine\DBAL\Driver\Exception} instead
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class DB2Exception extends AbstractDriverException
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
use Doctrine\DBAL\Driver\Statement;
|
||||
use Doctrine\DBAL\Driver\FetchUtils;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCopyStreamToStream;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCreateTemporaryFile;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotWriteToTemporaryFile;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError;
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
use Doctrine\DBAL\Driver\Statement as StatementInterface;
|
||||
use Doctrine\DBAL\Driver\StatementIterator;
|
||||
use Doctrine\DBAL\FetchMode;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
@@ -11,14 +17,11 @@ use PDO;
|
||||
use ReflectionClass;
|
||||
use ReflectionObject;
|
||||
use ReflectionProperty;
|
||||
use ReturnTypeWillChange;
|
||||
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 assert;
|
||||
use function db2_bind_param;
|
||||
use function db2_execute;
|
||||
use function db2_fetch_array;
|
||||
@@ -36,6 +39,7 @@ use function func_get_args;
|
||||
use function func_num_args;
|
||||
use function fwrite;
|
||||
use function gettype;
|
||||
use function is_int;
|
||||
use function is_object;
|
||||
use function is_resource;
|
||||
use function is_string;
|
||||
@@ -46,7 +50,17 @@ use function stream_get_meta_data;
|
||||
use function strtolower;
|
||||
use function tmpfile;
|
||||
|
||||
class DB2Statement implements IteratorAggregate, Statement
|
||||
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;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Statement} instead
|
||||
*/
|
||||
class DB2Statement implements IteratorAggregate, StatementInterface, Result
|
||||
{
|
||||
/** @var resource */
|
||||
private $stmt;
|
||||
@@ -79,6 +93,8 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
private $result = false;
|
||||
|
||||
/**
|
||||
* @internal The statement can be only instantiated by its driver connection.
|
||||
*
|
||||
* @param resource $stmt
|
||||
*/
|
||||
public function __construct($stmt)
|
||||
@@ -91,35 +107,39 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
*/
|
||||
public function bindValue($param, $value, $type = ParameterType::STRING)
|
||||
{
|
||||
assert(is_int($param));
|
||||
|
||||
return $this->bindParam($param, $value, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null)
|
||||
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null)
|
||||
{
|
||||
assert(is_int($param));
|
||||
|
||||
switch ($type) {
|
||||
case ParameterType::INTEGER:
|
||||
$this->bind($column, $variable, DB2_PARAM_IN, DB2_LONG);
|
||||
$this->bind($param, $variable, DB2_PARAM_IN, DB2_LONG);
|
||||
break;
|
||||
|
||||
case ParameterType::LARGE_OBJECT:
|
||||
if (isset($this->lobs[$column])) {
|
||||
[, $handle] = $this->lobs[$column];
|
||||
if (isset($this->lobs[$param])) {
|
||||
[, $handle] = $this->lobs[$param];
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
$handle = $this->createTemporaryFile();
|
||||
$path = stream_get_meta_data($handle)['uri'];
|
||||
|
||||
$this->bind($column, $path, DB2_PARAM_FILE, DB2_BINARY);
|
||||
$this->bind($param, $path, DB2_PARAM_FILE, DB2_BINARY);
|
||||
|
||||
$this->lobs[$column] = [&$variable, $handle];
|
||||
$this->lobs[$param] = [&$variable, $handle];
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->bind($column, $variable, DB2_PARAM_IN, DB2_CHAR);
|
||||
$this->bind($param, $variable, DB2_PARAM_IN, DB2_CHAR);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -127,29 +147,27 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|string $parameter Parameter position or name
|
||||
* @param mixed $variable
|
||||
* @param int $position Parameter position
|
||||
* @param mixed $variable
|
||||
*
|
||||
* @throws DB2Exception
|
||||
*/
|
||||
private function bind($parameter, &$variable, int $parameterType, int $dataType) : void
|
||||
private function bind($position, &$variable, int $parameterType, int $dataType): void
|
||||
{
|
||||
$this->bindParam[$parameter] =& $variable;
|
||||
$this->bindParam[$position] =& $variable;
|
||||
|
||||
if (! db2_bind_param($this->stmt, $parameter, 'variable', $parameterType, $dataType)) {
|
||||
throw new DB2Exception(db2_stmt_errormsg());
|
||||
if (! db2_bind_param($this->stmt, $position, 'variable', $parameterType, $dataType)) {
|
||||
throw StatementError::new($this->stmt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated Use free() instead.
|
||||
*/
|
||||
public function closeCursor()
|
||||
{
|
||||
if (! $this->stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->bindParam = [];
|
||||
|
||||
if (! db2_free_result($this->stmt)) {
|
||||
@@ -166,15 +184,13 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
*/
|
||||
public function columnCount()
|
||||
{
|
||||
if (! $this->stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return db2_num_fields($this->stmt);
|
||||
return db2_num_fields($this->stmt) ?: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated The error information is available via exceptions.
|
||||
*/
|
||||
public function errorCode()
|
||||
{
|
||||
@@ -183,6 +199,8 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated The error information is available via exceptions.
|
||||
*/
|
||||
public function errorInfo()
|
||||
{
|
||||
@@ -197,10 +215,6 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
*/
|
||||
public function execute($params = null)
|
||||
{
|
||||
if (! $this->stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($params === null) {
|
||||
ksort($this->bindParam);
|
||||
|
||||
@@ -230,7 +244,7 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
$this->lobs = [];
|
||||
|
||||
if ($retval === false) {
|
||||
throw new DB2Exception(db2_stmt_errormsg());
|
||||
throw StatementError::new($this->stmt);
|
||||
}
|
||||
|
||||
$this->result = true;
|
||||
@@ -240,6 +254,8 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated Use one of the fetch- or iterate-related methods.
|
||||
*/
|
||||
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
|
||||
{
|
||||
@@ -252,7 +268,10 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn() instead.
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
return new StatementIterator($this);
|
||||
@@ -260,6 +279,8 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead.
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
@@ -311,6 +332,8 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead.
|
||||
*/
|
||||
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
|
||||
{
|
||||
@@ -321,12 +344,16 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
while (($row = $this->fetch(...func_get_args())) !== false) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FetchMode::COLUMN:
|
||||
while (($row = $this->fetchColumn()) !== false) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
while (($row = $this->fetch($fetchMode)) !== false) {
|
||||
$rows[] = $row;
|
||||
@@ -338,6 +365,8 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated Use fetchOne() instead.
|
||||
*/
|
||||
public function fetchColumn($columnIndex = 0)
|
||||
{
|
||||
@@ -350,6 +379,64 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
return $row[$columnIndex] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchNumeric()
|
||||
{
|
||||
if (! $this->result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return db2_fetch_array($this->stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchAssociative()
|
||||
{
|
||||
// do not try fetching from the statement if it's not expected to contain the result
|
||||
// in order to prevent exceptional situation
|
||||
if (! $this->result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return db2_fetch_assoc($this->stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchOne()
|
||||
{
|
||||
return FetchUtils::fetchOne($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchAllNumeric(): array
|
||||
{
|
||||
return FetchUtils::fetchAllNumeric($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchAllAssociative(): array
|
||||
{
|
||||
return FetchUtils::fetchAllAssociative($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchFirstColumn(): array
|
||||
{
|
||||
return FetchUtils::fetchFirstColumn($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -358,12 +445,21 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
return @db2_num_rows($this->stmt) ? : 0;
|
||||
}
|
||||
|
||||
public function free(): void
|
||||
{
|
||||
$this->bindParam = [];
|
||||
|
||||
db2_free_result($this->stmt);
|
||||
|
||||
$this->result = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts a stdClass object to the given class name mapping its' properties.
|
||||
*
|
||||
* @param stdClass $sourceObject Object to cast from.
|
||||
* @param string|object $destinationClass Name of the class or class instance to cast to.
|
||||
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
|
||||
* @param stdClass $sourceObject Object to cast from.
|
||||
* @param class-string|object $destinationClass Name of the class or class instance to cast to.
|
||||
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
@@ -433,7 +529,7 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
$handle = @tmpfile();
|
||||
|
||||
if ($handle === false) {
|
||||
throw new DB2Exception('Could not create temporary file: ' . error_get_last()['message']);
|
||||
throw CannotCreateTemporaryFile::new(error_get_last());
|
||||
}
|
||||
|
||||
return $handle;
|
||||
@@ -445,10 +541,10 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
*
|
||||
* @throws DB2Exception
|
||||
*/
|
||||
private function copyStreamToStream($source, $target) : void
|
||||
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']);
|
||||
throw CannotCopyStreamToStream::new(error_get_last());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,10 +553,10 @@ class DB2Statement implements IteratorAggregate, Statement
|
||||
*
|
||||
* @throws DB2Exception
|
||||
*/
|
||||
private function writeStringToStream(string $string, $target) : void
|
||||
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']);
|
||||
throw CannotWriteToTemporaryFile::new(error_get_last());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
77
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DataSourceName.php
vendored
Normal file
77
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DataSourceName.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
use function implode;
|
||||
use function sprintf;
|
||||
use function strpos;
|
||||
|
||||
/**
|
||||
* IBM DB2 DSN
|
||||
*/
|
||||
final class DataSourceName
|
||||
{
|
||||
/** @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 array<string,mixed> $params
|
||||
*/
|
||||
public static function fromArray(array $params): self
|
||||
{
|
||||
$chunks = [];
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
$chunks[] = sprintf('%s=%s', $key, $value);
|
||||
}
|
||||
|
||||
return new self(implode(';', $chunks));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object from the given DBAL connection parameters.
|
||||
*
|
||||
* @param array<string,mixed> $params
|
||||
*/
|
||||
public static function fromConnectionParameters(array $params): self
|
||||
{
|
||||
if (isset($params['dbname']) && strpos($params['dbname'], '=') !== false) {
|
||||
return new self($params['dbname']);
|
||||
}
|
||||
|
||||
$dsnParams = [];
|
||||
|
||||
foreach (
|
||||
[
|
||||
'host' => 'HOSTNAME',
|
||||
'port' => 'PORT',
|
||||
'protocol' => 'PROTOCOL',
|
||||
'dbname' => 'DATABASE',
|
||||
'user' => 'UID',
|
||||
'password' => 'PWD',
|
||||
] as $dbalParam => $dsnParam
|
||||
) {
|
||||
if (! isset($params[$dbalParam])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dsnParams[$dsnParam] = $params[$dbalParam];
|
||||
}
|
||||
|
||||
return self::fromArray($dsnParams);
|
||||
}
|
||||
}
|
||||
9
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Driver.php
vendored
Normal file
9
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Driver.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
final class Driver extends DB2Driver
|
||||
{
|
||||
}
|
||||
29
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php
vendored
Normal file
29
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\IBMDB2\DB2Exception;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class CannotCopyStreamToStream extends DB2Exception
|
||||
{
|
||||
/**
|
||||
* @psalm-param array{message: string}|null $error
|
||||
*/
|
||||
public static function new(?array $error): self
|
||||
{
|
||||
$message = 'Could not copy source stream to temporary file';
|
||||
|
||||
if ($error !== null) {
|
||||
$message .= ': ' . $error['message'];
|
||||
}
|
||||
|
||||
return new self($message);
|
||||
}
|
||||
}
|
||||
29
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php
vendored
Normal file
29
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\IBMDB2\DB2Exception;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class CannotCreateTemporaryFile extends DB2Exception
|
||||
{
|
||||
/**
|
||||
* @psalm-param array{message: string}|null $error
|
||||
*/
|
||||
public static function new(?array $error): self
|
||||
{
|
||||
$message = 'Could not create temporary file';
|
||||
|
||||
if ($error !== null) {
|
||||
$message .= ': ' . $error['message'];
|
||||
}
|
||||
|
||||
return new self($message);
|
||||
}
|
||||
}
|
||||
29
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotWriteToTemporaryFile.php
vendored
Normal file
29
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotWriteToTemporaryFile.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\IBMDB2\DB2Exception;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class CannotWriteToTemporaryFile extends DB2Exception
|
||||
{
|
||||
/**
|
||||
* @psalm-param array{message: string}|null $error
|
||||
*/
|
||||
public static function new(?array $error): self
|
||||
{
|
||||
$message = 'Could not write string to temporary file';
|
||||
|
||||
if ($error !== null) {
|
||||
$message .= ': ' . $error['message'];
|
||||
}
|
||||
|
||||
return new self($message);
|
||||
}
|
||||
}
|
||||
26
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/ConnectionError.php
vendored
Normal file
26
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/ConnectionError.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
use function db2_conn_error;
|
||||
use function db2_conn_errormsg;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class ConnectionError extends AbstractException
|
||||
{
|
||||
/**
|
||||
* @param resource $connection
|
||||
*/
|
||||
public static function new($connection): self
|
||||
{
|
||||
return new self(db2_conn_errormsg($connection), db2_conn_error($connection));
|
||||
}
|
||||
}
|
||||
23
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/ConnectionFailed.php
vendored
Normal file
23
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/ConnectionFailed.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
use function db2_conn_error;
|
||||
use function db2_conn_errormsg;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class ConnectionFailed extends AbstractException
|
||||
{
|
||||
public static function new(): self
|
||||
{
|
||||
return new self(db2_conn_errormsg(), db2_conn_error());
|
||||
}
|
||||
}
|
||||
27
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/PrepareFailed.php
vendored
Normal file
27
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/PrepareFailed.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class PrepareFailed extends AbstractException
|
||||
{
|
||||
/**
|
||||
* @psalm-param array{message: string}|null $error
|
||||
*/
|
||||
public static function new(?array $error): self
|
||||
{
|
||||
if ($error === null) {
|
||||
return new self('Unknown error');
|
||||
}
|
||||
|
||||
return new self($error['message']);
|
||||
}
|
||||
}
|
||||
26
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/StatementError.php
vendored
Normal file
26
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/StatementError.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
use function db2_stmt_error;
|
||||
use function db2_stmt_errormsg;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class StatementError extends AbstractException
|
||||
{
|
||||
/**
|
||||
* @param resource $statement
|
||||
*/
|
||||
public static function new($statement): self
|
||||
{
|
||||
return new self(db2_stmt_errormsg($statement), db2_stmt_error($statement));
|
||||
}
|
||||
}
|
||||
7
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Statement.php
vendored
Normal file
7
vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/Statement.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
final class Statement extends DB2Statement
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user