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
這將在您的屏幕上顯示執行的查詢,而不是在開發工具中 –