2015-01-26 34 views
2

當我dd(\DB::getQueryLog())我得到類似如下:獲取綁定的Laravel雄辯查詢到位

array (size=3) 
     'query' => string 'select * from `clicks` where `clicks`.`user_id` in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and `created_at` between ? and ?' (length=114) 
     'bindings' => 
     array (size=12) 
      0 => int 70 
      1 => int 69 
      2 => int 68 
      3 => int 67 
      4 => int 66 
      5 => int 65 
      6 => int 64 
      7 => int 63 
      8 => int 60 
      9 => int 58 
      10 => 
      object(Carbon\Carbon)[681] 
       public 'date' => string '2014-12-27 20:06:39.000000' (length=26) 
       public 'timezone_type' => int 3 
       public 'timezone' => string 'UTC' (length=3) 
      11 => 
      object(Carbon\Carbon)[684] 
       public 'date' => string '2015-01-26 20:06:39.000000' (length=26) 
       public 'timezone_type' => int 3 
       public 'timezone' => string 'UTC' (length=3) 
     'time' => float 932.67 

如何得到查詢的所有綁定全部到位這樣我就可以把它複製到MySQL工作臺和修補程序與它不必手動添加這些綁定每次?

回答

2

實際的SQL字符串在PHP的一端永遠不可用。您可以嘗試手動解決問題,並用綁定替換?

echo vsprintf(str_replace('?', '%s', $queryString), $bindings);