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

QueryBuilder ignores LIMIT with Oracle #11813

Closed
cleithoff opened this issue May 20, 2016 · 2 comments
Closed

QueryBuilder ignores LIMIT with Oracle #11813

cleithoff opened this issue May 20, 2016 · 2 comments

Comments

@cleithoff
Copy link

When you use Phalcon\Mvc\Model\Query\Builder with Oracle the method limit does nothing.

Example from inside controller action:

$query = $this->modelsManager->createBuilder()->from('mytable');
$query->limit(100,200);
$result = $query->getQuery()->execute();

The $result has all records from that table. So limit is ignored. When I looked into the sql log I see following query:

SELECT * FROM (SELECT Z1., ROWNUM PHALCON_RN FROM (SELECT mytable. FROM mytable) Z1)

As you can see the WHERE conditions are missing.

I tested these under Phalcon 2.1.0 RC1 and 2.0.11 with windows dlls from your website.

With MySql+Ubuntu it is working! So maybe this issue depends on Phalcon\Db\Dialect\Oracle. The builder creates PHQL with parameter bindings and after that when Phalcon\Db\Dialect\Oracle is used to create the real query no real limit and offset number are found (maybe it is a string :APL0: or empty/0) and this caused that no where clauses are created.

Workaround: Use get phql from builder and create query from phql. Before you will replace LIMIT and OFFSET bindings with your parameters.

$query = $this->modelsManager->createBuilder()->from('mytable');
$query->limit(100,200);

$phql = $query->getPhql();
$phql = str_replace(':APL0:', $limit, $phql);
$phql = str_replace(':APL1:', $offset, $phql);
$query = $this->modelsManager->createQuery($phql);

$result = $query->execute();

@lubberscorrado
Copy link

Thanks for the Workaround, i just came across the exact same issue and was pulling my hair off
Hopefully this can be fixed directly in phalcon soon 😀

@sergeyklay
Copy link
Contributor

Phalcon does not support Oracle. Refer to #12008

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants