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

HAVING on queryBuilder with JOIN doesn't work #10257

Closed
vikilaboy opened this issue May 6, 2015 · 6 comments
Closed

HAVING on queryBuilder with JOIN doesn't work #10257

vikilaboy opened this issue May 6, 2015 · 6 comments

Comments

@vikilaboy
Copy link

I have an array with parameters in order to build the query but if there's a JOIN in that i receive this " Syntax error, unexpected EOF ". I'm using Phalcon 2.0. This seems to be only on 2.0, before update i didn't receive this error.

$conditions = array (
            'having' => 'name LIKE \'%bla bla%\'',
            'models' =>
                array (
                    'a' => 'Rinf\\Models\\Clocking',
                ),
            'columns' =>
                array (
                    0 => 'a.id',
                    1 => 'a.idEmployee',
                    2 => 'a.dateFrom',
                    3 => 'a.dateTo',
                    4 => 'a.countableDays',
                    5 => 'IF(a.hours < 0.1, \'\', a.hours) as hours',
                    6 => 'a.services',
                    7 => 'a.observation',
                    8 => 'a.dateAdd',
                    9 => 'e.erpCode',
                    10 => 'ac.name AS activity',
                    11 => 'ac.reference',
                    12 => 'ct.name AS contractType',
                    13 => 'co.name AS company',
                    14 => 'e.status',
                    15 => 'CONCAT_WS(\' \', e.firstname, e.lastname) AS name',
                ),
            'joins' =>
                array (
                    0 =>
                        array (
                            0 => 'Rinf\\Models\\Activity',
                            1 => 'a.idActivity = ac.id',
                            2 => 'ac',
                            3 => 'INNER',
                        ),
                    1 =>
                        array (
                            0 => 'Rinf\\Models\\Employee',
                            1 => 'a.idEmployee = e.id',
                            2 => 'e',
                            3 => 'INNER',
                        ),
                    2 =>
                        array (
                            0 => 'Rinf\\Models\\ContractType',
                            1 => 'e.idContractType = ct.id',
                            2 => 'ct',
                            3 => 'INNER',
                        ),
                    3 =>
                        array (
                            0 => 'Rinf\\Models\\Company',
                            1 => 'e.idCompany = co.id',
                            2 => 'co',
                            3 => 'INNER',
                        ),
                ),
        );
        $builder = $this->modelsManager->createBuilder($conds);
        $collections = $builder->getQuery()->execute();

if i run $builder->getPhql() is seems the query were builded correctly.

SELECT a.id, a.idEmployee, a.dateFrom, a.dateTo, a.countableDays, IF(a.hours < 0.1, '', a.hours) as hours, a.services, a.observation, a.dateAdd, e.erpCode, ac.name AS activity, ac.reference, ct.name AS contractType, co.name AS company, e.status, CONCAT_WS(' ', e.firstname, e.lastname) AS name FROM [Rinf\Models\Clocking] AS [a] INNER JOIN [Rinf\Models\Activity] AS [ac] ON a.idActivity = ac.id INNER JOIN [Rinf\Models\Employee] AS [e] ON a.idEmployee = e.id INNER JOIN [Rinf\Models\ContractType] AS [ct] ON e.idContractType = ct.id INNER JOIN [Rinf\Models\Company] AS [co] ON e.idCompany = co.id HAVING name LIKE '%bla bla%'
@KorsaR-ZN
Copy link
Contributor

@vikilaboy This has been fixed in the branch 2.0.x

@vikilaboy
Copy link
Author

I'm on master now, should i checkout in 2.0.x ? or it will be on master also ?

Thank you !

[root@dev /usr/share/cphalcon (master) ]$ git branch -a
  1.3.5
  2.0.0
* master
  remotes/origin/0.4.5
  remotes/origin/0.5.0
  remotes/origin/0.5.1
  remotes/origin/0.5.2
  remotes/origin/0.5.3
  remotes/origin/0.6.0
  remotes/origin/0.6.1
  remotes/origin/0.7.0
  remotes/origin/0.8.0
  remotes/origin/0.9.0
  remotes/origin/0.9.1
  remotes/origin/1.0.0
  remotes/origin/1.0.1
  remotes/origin/1.1.0
  remotes/origin/1.2.0
  remotes/origin/1.2.1
  remotes/origin/1.2.2
  remotes/origin/1.2.3
  remotes/origin/1.2.4
  remotes/origin/1.2.5
  remotes/origin/1.2.6
  remotes/origin/1.3.0
  remotes/origin/1.3.1
  remotes/origin/1.3.2
  remotes/origin/1.3.3
  remotes/origin/1.3.4
  remotes/origin/1.3.5
  remotes/origin/1.30
  remotes/origin/2.0.0
  remotes/origin/2.0.x
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/illd
  remotes/origin/master
  remotes/origin/revert-10141-patch-1
  remotes/origin/revert-9927-patch-1

@KorsaR-ZN
Copy link
Contributor

@vikilaboy On master it will be later...
The branch 2.0.x currently is not stable, after merge #10253, #10251 will better

@vikilaboy
Copy link
Author

@KorsaR-ZN Then I'm gonna wait for the merge or switch to 1.3.5. Thanks a lot

@KorsaR-ZN
Copy link
Contributor

@vikilaboy The solution to your problem now in master
Please try again...

@vikilaboy
Copy link
Author

Now it works fine.

Thank you !
Good job guys !

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

2 participants