MSODBCSQL17 and SQL Server 2008 findOneBy(): Incorrect syntax near 'OFFSET' #6947

Open
opened 2026-01-22 15:42:01 +01:00 by admin · 1 comment
Owner

Originally created by @Adi-18 on GitHub (Mar 11, 2022).

Bug Report

Q A
Version 3.2.2
Symfony 6.0.4
PHP 8.1

Summary

Application that connects to a remote SQL Server 2008 R2 with MSODBCSQL17
and SQLSRV Doctrine DBAL driver in a Docker container running PHP-FPM 8.1 and Apache.

Using Doctrine to persist entities and retrieve one more than one record works without problems, but the findOneBy() method throws 1 DBAL exception and 1 SQLSRV Exception.

Current behavior

When retrieving entities with the default findOneBy() method, Symfony throws the following: Incorrect syntax near 'OFFSET'

Also follows don't works:

        $qb = $this->createQueryBuilder('c');
        $qb
            ->where('c.operator = :loginId')
            ->setParameter('loginId', $loginId)
            ->orderBy('c.workDate','ASC')
            ->setMaxResults(1)
        ;
        return $qb->getQuery()->getSingleResult();

I need to select first row of my database.
Issue [ doctrine/dbal#3159] did not help or I don't understand it.

Originally created by @Adi-18 on GitHub (Mar 11, 2022). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |----------- | ------ | Version | 3.2.2 | Symfony | 6.0.4 | PHP | 8.1 #### Summary Application that connects to a remote SQL Server 2008 R2 with MSODBCSQL17 and SQLSRV Doctrine DBAL driver in a Docker container running PHP-FPM 8.1 and Apache. Using Doctrine to persist entities and retrieve one more than one record works without problems, but the findOneBy() method throws 1 DBAL exception and 1 SQLSRV Exception. #### Current behavior When retrieving entities with the default findOneBy() method, Symfony throws the following: Incorrect syntax near 'OFFSET' Also follows don't works: ``` $qb = $this->createQueryBuilder('c'); $qb ->where('c.operator = :loginId') ->setParameter('loginId', $loginId) ->orderBy('c.workDate','ASC') ->setMaxResults(1) ; return $qb->getQuery()->getSingleResult(); ``` I need to select first row of my database. Issue [ doctrine/dbal#3159] did not help or I don't understand it.
admin added the Bug label 2026-01-22 15:42:01 +01:00
Author
Owner

@Damien-Unsolite commented on GitHub (Apr 26, 2022):

Hi. Same problem for me.
It seems Doctrine 3 must be used now for SQLServer "version 2012 and above"
https://www.doctrine-project.org/projects/doctrine-dbal/en/3.2/reference/platforms.html
Doctrine 2 can use SQLServer 2000 and above.
That's very bad for me (and my project)...

@Damien-Unsolite commented on GitHub (Apr 26, 2022): Hi. Same problem for me. It seems Doctrine 3 must be used now for SQLServer "version 2012 and above" https://www.doctrine-project.org/projects/doctrine-dbal/en/3.2/reference/platforms.html Doctrine 2 can use SQLServer 2000 and above. That's very bad for me (and my project)...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6947