Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBAL-1823: Doctrine2 + pdo_sqlsrv the createQueryBuilder() Order By with varchar field does not work #1351

Closed
doctrinebot opened this issue Dec 3, 2015 · 1 comment
Labels

Comments

@doctrinebot
Copy link

Jira issue originally created by user leoFelipe:

I am creating a QueryBuilder receiving values to createQueryBuilder() coming by parameter. I created testing in my local database with pdo_mysql driver and it worked perfectly, both ordered by a field of type int (id) or by a field of type varchar (titulo).

However, after testing in other database in external server with pdo_sqlsrv driver (and also sqlsrv driver) works when the "order by" is by a field of type int (id), but when ordination by a field of type varchar (titulo) gives timeout in the connection.

The following code prints the return of the mySQL database and the SQLServer database:

public function getBy($fields, $orderBy, $where = null, $params = null)
{
    if (empty($where))
        $where = '1 = 1';

    $query = $this->getEntityManager()->createQueryBuilder()
        ->select($fields)
        ->from($this->entity, $this->alias)
        ->where($where)
        ->add('orderBy', $orderBy)
        ->setFirstResult(URIHelper::$arrayParams['offset'])
        ->setMaxResults(URIHelper::$arrayParams['limit'])
        ->getQuery();

    if (!empty($params))
        $query->setParameters($params);

    print_r($query->getSQL());
    //print_r($query->getParameters());
    //print_r($query->getArrayResult());
    //die();
    return $query->getArrayResult();
}

Return OK when I use MySQL database ordination titulo(varchar):
!img01.png|thumbnail!


Return OK when you use SQLServer database ordination id (int):
!img02.png|thumbnail!


Return ERROR when I use SQLServer database ordination titulo(varchar):
!img03.png|thumbnail!

@github-actions
Copy link

github-actions bot commented Oct 5, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants