Skip to content

Grouping WHERE conditions with ezSQL v4 PDO #164

@dpDesignz

Description

@dpDesignz

I know this is probably going to be very obvious, but can anyone please show me how to group my WHERE conditions when using the selecting function? I know how to write it in standard SQL, but I can't for the life of me work this out using ezSQL.

What I'm wanting

SELECT user_id, user_password, user_password_key FROM users WHERE (user_login = $userData OR user_email = $userData) AND user_status=1

What I've tried

$db->selecting('users', 'user_id, user_password, user_password_key', where(eq('user_status', '1', _AND)), where(eq('user_login', $userData, _OR ), eq('user_email', $userData ))); $db->selecting('users', 'user_id, user_password, user_password_key', where(eq('user_status', '1')), where(eq('user_login', $userData, _OR ), eq('user_email', $userData ))); $db->selecting('users', 'user_id, user_password, user_password_key', $db->where(eq('user_login', $userData, _OR ), eq('user_email', $userData )), $db->where('user_status', '1')); $db->selecting('users', 'user_id, user_password, user_password_key', eq('user_login', $userData, _OR ), eq('user_email', $userData ), $db->where('user_status', '1') ); 

It works if I remove the condition for the user_status, but when it's in there it just returns NULL.

Metadata

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