Case-sensitive where statement in laravel

后端 未结 2 516
滥情空心
滥情空心 2021-02-04 04:50

How can I do a case-sensitive string match with laravel?


SELECT * FROM `invites` WHERE `token`=\'OGwie2e2985tOEGewgu23hUFs\'

Can be done as

相关标签:
2条回答
  • 2021-02-04 05:22

    You'll need to use DB::raw(), perhaps something like

    Invite::where(DB::raw('BINARY `token`'), $token)->first();
    

    or alternatively:

    Invite::whereRaw("BINARY `token`= ?",[$token])->first()
    
    0 讨论(0)
  • 2021-02-04 05:27

    A little bit late but still wouldn't this be a better alternative?

    Invite::whereRaw("BINARY `token`= ?", array($token))->first()
    
    0 讨论(0)
提交回复
热议问题