0
我想测试MySQL中Laravel函数的输出,为此我需要将代码翻译成SQL请求。将Laravel函数转换为SQL请求来测试
功能:
return DB::table('products')
->leftJoin('product_locations', 'products.id', '=', 'product_locations.productId')
->select(DB::raw('IF(product_locations.id is not null,concat(product_locations.id,"-","M"),concat(products.id,"-","N")) as id'), DB::raw('IF(product_locations.id is not null,1,0) as multilocation'), 'products.productName', 'products.productName as text', 'product_locations.productLocationName', 'product_locations.binLocationName', 'product_locations.unitCost', 'product_locations.amount')
->orderBy('products.productName')
->distinct()
->get();
感谢您的帮助,我试图按照您指定的方式使用查询日志记录,但在“chrom的开发人员工具”上看不到任何结果 – allam
这将在您的屏幕上显示执行的查询,而不是在开发工具中 –