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

Can not add multiple selections as condition on the same column #14

Closed
michal-kusy opened this issue Jun 20, 2014 · 3 comments
Closed

Can not add multiple selections as condition on the same column #14

michal-kusy opened this issue Jun 20, 2014 · 3 comments
Labels

Comments

@michal-kusy
Copy link

@michal-kusy michal-kusy commented Jun 20, 2014

Example code:

    $q = $db->table('users');
    foreach(array('admin','user') as $role) {
       $q->where('id',
                         $db->table('user_role')
                               ->select('user_id')
                               ->where('role_id',$role));
    }

Example code adds only first selection, because of hash check in SqlBuilder.php line 200. It's because Selection does not have any unique public property and so it's always translated as empty object {} in JSON.

@matej21

This comment has been minimized.

Copy link
Contributor

@matej21 matej21 commented Jun 20, 2014

There is syntax for filtering by another table value:

$db->table('users')->where(':user_role.role_id', array('admin', 'user'))
@michal-kusy

This comment has been minimized.

Copy link
Author

@michal-kusy michal-kusy commented Jun 20, 2014

I know the example is simple. But it proves the issue.
I hit this issue when sub selects were more complicated - like multiple AND conditions on multiple columns etc.

This syntax just didn't suit my needs.

The real issue is that json_encode(array('condition',$selection)) always ends up as "['condition',{}]". Because of the md5 check it's possible to assign only 1 selection to 1 condition.

I guess this restriction is not necessary.

@hrach hrach added the 1-feature label Oct 18, 2014
norbe added a commit to norbe/database that referenced this issue Feb 24, 2016
norbe added a commit to norbe/database that referenced this issue Feb 24, 2016
norbe added a commit to norbe/database that referenced this issue Mar 4, 2016
dg added a commit that referenced this issue Mar 4, 2016
dg added a commit that referenced this issue Mar 4, 2016
dg added a commit that referenced this issue Mar 4, 2016
@norbe

This comment has been minimized.

Copy link
Contributor

@norbe norbe commented May 10, 2016

This issue should be fixed..

@dg dg closed this May 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.