composer update

This commit is contained in:
Manish Verma
2018-12-05 10:50:52 +05:30
parent 9eabcacfa7
commit 4addd1e9c6
3328 changed files with 156676 additions and 138988 deletions

View File

@@ -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);
}

View File

@@ -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.

View File

@@ -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);
}

View File

@@ -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);
}
}

View 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;
}
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -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.

View File

@@ -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}

View File

@@ -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;
}
/**

View File

@@ -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.
*/

View File

@@ -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(),
];
}

View File

@@ -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'];
}

View File

@@ -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
{
}

View File

@@ -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']);
}
}
}

View File

@@ -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
{
/**

View File

@@ -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,

View File

@@ -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
{

View File

@@ -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;
}

View File

@@ -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.
*/

View File

@@ -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;

View File

@@ -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
*/

View File

@@ -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;
}

View File

@@ -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);
}
}
/**

View File

@@ -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)

View File

@@ -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.
*/

View File

@@ -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'])) {

View File

@@ -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.
*/

View File

@@ -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'])) {

View File

@@ -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.
*/

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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
{

View File

@@ -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);
}

View File

@@ -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)
);

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;
/**

View File

@@ -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();
}
}

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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
{

View File

@@ -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.
*/

View File

@@ -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;
}
}