title: Laravel: User-defined MySQL variables always NULL in Laravel but not in MySQL CLI
body: <p>I have a query with a nested select that uses the result of the first select. I have the query working perfectly as I tested using Sequel Pro's query checker. It returns my desired results. When I pass this query over to Laravel and run a test on it using a simple <code>echo</code> statement, it outputs <code>NULL</code>.</p>
  
  <p>Here is my PHP code and query:</p>
  
  <pre><code>$crons = DB::select('
      SELECT @quiet_crons:=ROUND(SUM(TIME_TO_SEC(TIMEDIFF(`end_time`, `start_time`))/60/15))
      AS quiet_crons,
      FLOOR(SUM(TIME_TO_SEC(TIMEDIFF(TIME('24:00'), TIME(NOW())))/60/15-@quiet_crons))
      AS remaining_crons
      FROM `quiet_periods`
      WHERE `day` = DAYNAME(NOW())
  ');
  </code></pre>
  
  <p>And this is the output from the console:</p>
  
  <pre><code>array(1) {
    [0]=&gt;
    object(stdClass)#689 (2) {
      ["quiet_crons"]=&gt;
      string(2) "24"
      ["remaining_crons"]=&gt;
      NULL
    }
  }
  </code></pre>
  
  <p>The <code>remaining_crons</code> result should never be <code>NULL</code>.</p>
  
  <p><em>Please Note:</em> I saw an article on here that talked about user-defined MySQL variables in Laravel and I tried the solution yet it did not solve my problem. This is the link I am referring to:
  <a href="https://stackoverflow.com/questions/16319132/user-defined-mysql-variables-in-laravel-3">User-defined MySQL variables in Laravel 3?</a></p>