Replaced PDO::CASE_* constants

parent 1d09430f
......@@ -51,12 +51,16 @@ Using the following code block in your initialization will:
.. code-block:: php
<?php
use Doctrine\DBAL\ColumnCase;
use Doctrine\DBAL\Portability\Connection as PortableConnection;
$params = array(
// vendor specific configuration
//...
'wrapperClass' => 'Doctrine\DBAL\Portability\Connection',
'portability' => \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL,
'fetch_case' => \PDO::CASE_LOWER,
'wrapperClass' => PortableConnection::class,
'portability' => PortableConnection::PORTABILITY_ALL,
'fetch_case' => PortableConnection::LOWER,
);
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.
Doctrine ships with lists of keywords for every supported 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``
namespace.
\ No newline at end of file
namespace.
......@@ -20,6 +20,7 @@
namespace Doctrine\DBAL\Portability;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\ColumnCase;
/**
* Portability wrapper for a Connection.
......@@ -83,12 +84,13 @@ class Connection extends \Doctrine\DBAL\Connection
}
$this->portability = $params['portability'];
}
if (isset($params['fetch_case']) && $this->portability & self::PORTABILITY_FIX_CASE) {
if ($this->_conn instanceof \Doctrine\DBAL\Driver\PDOConnection) {
// make use of c-level support for case handling
$this->_conn->setAttribute(\PDO::ATTR_CASE, $params['fetch_case']);
} 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 @@
namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\ColumnCase;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\FetchMode;
......@@ -28,13 +29,17 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
* @param int $case
* @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) {
$params = $this->_conn->getParams();
$params['wrapperClass'] = 'Doctrine\DBAL\Portability\Connection';
$params['portability'] = $portabilityMode;
$params['fetch_case'] = $case;
$params['wrapperClass'] = ConnectionPortability::class;
$params['portability'] = $portabilityMode;
$params['fetch_case'] = $case;
$this->portableConnection = DriverManager::getConnection($params, $this->_conn->getConfiguration(), $this->_conn->getEventManager());
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