Skip to content

2.0.6 - Bug on using queryBuilder again #10754

Closed
@FirePro

Description

Hello! I using Phalcon 2.0.6

Query builder have error on set limit and offset parameters. You need call $queryBuilder->getPhql() or $queryBuilder->getQuery() two times and you get four bind parameters...there should be two..

Number of method invocation parameters increases by 2

$queryBuilder = new \Phalcon\Mvc\Model\Query\Builder();
$queryBuilder->columns("Users.*");
$queryBuilder->addFrom("Users");
$queryBuilder->limit(10);
$queryBuilder->offset(10);
$queryBuilder->getPhql(); //now we have 2 bind parameters..it's nice...
$queryBuilder->getPhql(); //now we have 4 bind parameters..it's wrong...
$queryBuilder->getPhql(); //now we have 6 bind parameters..it's wrong...

After you have in dump

_bindParams => array [6]
AP0 - 10
AP1 - 10
AP2 - 10
AP3 - 10
AP4 - 10
AP5 - 10

Last call getPhql() return
SELECT Users.* FROM [Users] LIMIT :AP4: OFFSET :AP5:

It becomes impossible to execute query..After execute i get error: Invalid parameter number: number of bound variables does not match number of tokens

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions