dongyan1974 2019-08-13 03:10
浏览 31

使用ezSQL v4 PDO对WHERE条件进行分组

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.

Examples copied from https://github.com/ezSQL/ezSQL#example-for-using-prepare-statements-indirectly-with-above-shortcut-sql-methods

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度