Replaced PDO::CASE_* constants

parent 1d09430f
...@@ -51,12 +51,16 @@ Using the following code block in your initialization will: ...@@ -51,12 +51,16 @@ Using the following code block in your initialization will:
.. code-block:: php .. code-block:: php
<?php <?php
use Doctrine\DBAL\ColumnCase;
use Doctrine\DBAL\Portability\Connection as PortableConnection;
$params = array( $params = array(
// vendor specific configuration // vendor specific configuration
//... //...
'wrapperClass' => 'Doctrine\DBAL\Portability\Connection', 'wrapperClass' => PortableConnection::class,
'portability' => \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL, 'portability' => PortableConnection::PORTABILITY_ALL,
'fetch_case' => \PDO::CASE_LOWER, 'fetch_case' => PortableConnection::LOWER,
); );
This sort of portability handling is pretty expensive because all the result This sort of portability handling is pretty expensive because all the result
...@@ -80,4 +84,4 @@ This functionality is only implemented with Doctrine 2.1 upwards. ...@@ -80,4 +84,4 @@ This functionality is only implemented with Doctrine 2.1 upwards.
Doctrine ships with lists of keywords for every supported vendor. You Doctrine ships with lists of keywords for every supported vendor. You
can access a keyword list through the schema manager of the vendor you can access a keyword list through the schema manager of the vendor you
are currently using or just instantiating it from the ``Doctrine\DBAL\Platforms\Keywords`` are currently using or just instantiating it from the ``Doctrine\DBAL\Platforms\Keywords``
namespace. namespace.
\ No newline at end of file
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
namespace Doctrine\DBAL\Portability; namespace Doctrine\DBAL\Portability;
use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\ColumnCase;
/** /**
* Portability wrapper for a Connection. * Portability wrapper for a Connection.
...@@ -83,12 +84,13 @@ class Connection extends \Doctrine\DBAL\Connection ...@@ -83,12 +84,13 @@ class Connection extends \Doctrine\DBAL\Connection
} }
$this->portability = $params['portability']; $this->portability = $params['portability'];
} }
if (isset($params['fetch_case']) && $this->portability & self::PORTABILITY_FIX_CASE) { if (isset($params['fetch_case']) && $this->portability & self::PORTABILITY_FIX_CASE) {
if ($this->_conn instanceof \Doctrine\DBAL\Driver\PDOConnection) { if ($this->_conn instanceof \Doctrine\DBAL\Driver\PDOConnection) {
// make use of c-level support for case handling // make use of c-level support for case handling
$this->_conn->setAttribute(\PDO::ATTR_CASE, $params['fetch_case']); $this->_conn->setAttribute(\PDO::ATTR_CASE, $params['fetch_case']);
} else { } else {
$this->case = ($params['fetch_case'] == \PDO::CASE_LOWER) ? CASE_LOWER : CASE_UPPER; $this->case = ($params['fetch_case'] == ColumnCase::LOWER) ? CASE_LOWER : CASE_UPPER;
} }
} }
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional; namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\ColumnCase;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\FetchMode;
...@@ -28,13 +29,17 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -28,13 +29,17 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
* @param int $case * @param int $case
* @return Connection * @return Connection
*/ */
private function getPortableConnection($portabilityMode = \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL, $case = \PDO::CASE_LOWER) private function getPortableConnection(
{ $portabilityMode = ConnectionPortability::PORTABILITY_ALL,
$case = ColumnCase::LOWER
) {
if (!$this->portableConnection) { if (!$this->portableConnection) {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$params['wrapperClass'] = 'Doctrine\DBAL\Portability\Connection';
$params['portability'] = $portabilityMode; $params['wrapperClass'] = ConnectionPortability::class;
$params['fetch_case'] = $case; $params['portability'] = $portabilityMode;
$params['fetch_case'] = $case;
$this->portableConnection = DriverManager::getConnection($params, $this->_conn->getConfiguration(), $this->_conn->getEventManager()); $this->portableConnection = DriverManager::getConnection($params, $this->_conn->getConfiguration(), $this->_conn->getEventManager());
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment