Mysql 在laravel CONCAT和md5上创建查询

Mysql 在laravel CONCAT和md5上创建查询,mysql,laravel,Mysql,Laravel,如何将我的查询转换为laravel?我的$ID是md5 $ID = "aa8c96cf79a656e7ef095871ec061888"; $sql = "SELECT * FROM orders WHERE md5(CONCAT(`id`,`email`)) = '{$ID}' || md5(CONCAT(`code`,`email`)) = '{$ID}' "; 谢谢试试这样的方法: $order = DB::table('orders')->whereraw('md5(CONCA

如何将我的查询转换为laravel?我的$ID是md5

$ID = "aa8c96cf79a656e7ef095871ec061888";

$sql = "SELECT * FROM orders WHERE md5(CONCAT(`id`,`email`)) = '{$ID}' || md5(CONCAT(`code`,`email`)) = '{$ID}' ";

谢谢

试试这样的方法:

$order = DB::table('orders')->whereraw('md5(CONCAT(`id`,`email`)) = ? || md5(CONCAT(`code`,`email`)) = ?',[$ID,$ID] );
有关更多详细信息,请参见此处:

这有什么用?为什么你用这种方式产生IDS?看起来像是对我。当然,既然你知道它是如何工作的,真的要考虑为什么你使用这个模式,它看起来不像是一个好的使用模式,将来会引起很多头痛。
$order = DB::table('orders')->whereraw('md5(CONCAT(`id`,`email`)) = ? || md5(CONCAT(`code`,`email`)) = ?',[$ID,$ID] );