diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index 0acf42f5a6c..d5a0720723c 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -490,21 +490,21 @@ where you can generate an arbitrary join with the following syntax: With an arbitrary join the result differs from the joins using a mapped property. The result of an arbitrary join is an one dimensional array with a mix of the entity from the ``SELECT`` and the joined entity fitting to the filtering of the query. In case of the example with ``User`` -and ``Blacklist``, it can look like this: +and ``Banlist``, it can look like this: - User -- Blacklist -- Blacklist +- Banlist +- Banlist - User -- Blacklist +- Banlist - User -- Blacklist -- Blacklist -- Blacklist +- Banlist +- Banlist +- Banlist -In this form of join, the ``Blacklist`` entities found by the filtering in the ``WITH`` part are not fetched by an accessor -method on ``User``, but are already part of the result. In case the accessor method for Blacklists is invoked on a User instance, -it loads all the related ``Blacklist`` objects corresponding to this ``User``. This change of behaviour needs to be considered +In this form of join, the ``Banlist`` entities found by the filtering in the ``WITH`` part are not fetched by an accessor +method on ``User``, but are already part of the result. In case the accessor method for Banlists is invoked on a User instance, +it loads all the related ``Banlist`` objects corresponding to this ``User``. This change of behaviour needs to be considered when the DQL is switched to an arbitrary join. .. note:: @@ -1283,13 +1283,14 @@ creating a class which extends ``AbstractHydrator``: _stmt->fetchAll(PDO::FETCH_ASSOC); + return $this->_stmt->fetchAll(FetchMode::FETCH_ASSOC); } } diff --git a/docs/en/reference/query-builder.rst b/docs/en/reference/query-builder.rst index 76ea5548469..ef330735167 100644 --- a/docs/en/reference/query-builder.rst +++ b/docs/en/reference/query-builder.rst @@ -252,8 +252,8 @@ while the named placeholders start with a : followed by a string. Calling ``setParameter()`` automatically infers which type you are setting as value. This works for integers, arrays of strings/integers, DateTime instances and for managed entities. If you want to set a type explicitly you can call -the third argument to ``setParameter()`` explicitly. It accepts either a PDO -type or a DBAL Type name for conversion. +the third argument to ``setParameter()`` explicitly. It accepts either a DBAL +Doctrine\DBAL\ParameterType::* or a DBAL Type name for conversion. .. note:: diff --git a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php index 3e47a96858b..4fad8e1e6cb 100644 --- a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php +++ b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php @@ -8,8 +8,8 @@ use DateTimeImmutable; use DateTimeInterface; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\Types; -use PDO; use function current; use function is_array; @@ -60,6 +60,6 @@ public static function inferType($value) : Connection::PARAM_STR_ARRAY; } - return PDO::PARAM_STR; + return ParameterType::STRING; } } diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 97e91ddbbd6..455e4acfa18 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -528,7 +528,7 @@ public function getRootEntities() * * @param string|int $key The parameter position or name. * @param mixed $value The parameter value. - * @param string|int|null $type PDO::PARAM_* or \Doctrine\DBAL\Types\Type::* constant + * @param string|int|null $type ParameterType::* or \Doctrine\DBAL\Types\Type::* constant * * @return static */ diff --git a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php index 27983f43051..95b63ebcf0c 100644 --- a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php +++ b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\ParameterType; use PDO; /** @@ -45,7 +46,7 @@ public function query() /** * {@inheritdoc} */ - public function quote($input, $type = PDO::PARAM_STR) + public function quote($input, $type = ParameterType::STRING) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php index bc458123334..c9790db09eb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php @@ -24,15 +24,12 @@ class DDC1225Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1225TestEntity1::class), - $this->_em->getClassMetadata(DDC1225TestEntity2::class), - ] - ); - } catch (PDOException $e) { - } + $this->_schemaTool->createSchema( + [ + $this->_em->getClassMetadata(DDC1225TestEntity1::class), + $this->_em->getClassMetadata(DDC1225TestEntity2::class), + ] + ); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php index 92ddd5b4886..561e8b2e838 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php @@ -21,12 +21,9 @@ class DDC1250Test extends OrmFunctionalTestCase protected function setUp(): void { parent::setUp(); - try { - $this->_schemaTool->createSchema( - [$this->_em->getClassMetadata(DDC1250ClientHistory::class)] - ); - } catch (PDOException $e) { - } + $this->_schemaTool->createSchema( + [$this->_em->getClassMetadata(DDC1250ClientHistory::class)] + ); } public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index c6b7578f537..df279c1a97d 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -8,10 +8,10 @@ use DateTime; use DateTimeImmutable; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Query\ParameterTypeInferer; use Doctrine\Tests\OrmTestCase; -use PDO; class ParameterTypeInfererTest extends OrmTestCase { @@ -20,8 +20,8 @@ public function providerParameterTypeInferer(): array { return [ [1, Type::INTEGER], - ['bar', PDO::PARAM_STR], - ['1', PDO::PARAM_STR], + ['bar', ParameterType::STRING], + ['1', ParameterType::STRING], [new DateTime(), Type::DATETIME], [new DateTimeImmutable(), Type::DATETIME_IMMUTABLE], [new DateInterval('P1D'), Type::DATEINTERVAL], diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index e666186112d..226490524e6 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -8,6 +8,7 @@ use DateTimeImmutable; use Doctrine\Common\Cache\Psr6\DoctrineProvider; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Internal\Hydration\IterableResult; use Doctrine\ORM\Query\Parameter; @@ -23,7 +24,6 @@ use Doctrine\Tests\Models\Generic\DateTimeModel; use Doctrine\Tests\OrmTestCase; use Generator; -use PDO; use Symfony\Component\Cache\Adapter\ArrayAdapter; use function assert; @@ -75,7 +75,7 @@ public function testSetParameters(): void public function testFree(): void { $query = $this->entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1'); - $query->setParameter(2, 84, PDO::PARAM_INT); + $query->setParameter(2, 84, ParameterType::INTEGER); $query->free(); @@ -87,7 +87,7 @@ public function testClone(): void $dql = 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1'; $query = $this->entityManager->createQuery($dql); - $query->setParameter(2, 84, PDO::PARAM_INT); + $query->setParameter(2, 84, ParameterType::INTEGER); $query->setHint('foo', 'bar'); $cloned = clone $query;