title: Get Result of Stored Procedure Laravel
body: <p>I am using Laravel 5.4 and MySql 5.7, PHP 5.6.
  I am trying to call a stored procedure (that does a SELECT query, joining multiple tables), and to get the result returned to my PHP.</p>
  
  <p>Here are the things I've unsuccessfully tried:</p>
  
  <p><strong>PHP 1:</strong></p>
  
  <pre><code>$result =  DB::select('CALL rentalsAvailables_get(?, ?, ?, ?)',
                  array(
                      'p0' =&gt; Carbon::now(),
                      'p1' =&gt; Carbon::now()-&gt;addDays(7),
                      'p2' =&gt; 100,
                      'p3' =&gt; 2
                  )
      );
  return var_dump($result);
  </code></pre>
  
  <p><strong>Result 1:</strong> </p>
  
  <pre><code>{
     "error": {
          "message": "SQLSTATE[HY000]: General error: 2031  (SQL: CALL rentalsAvailables_get(2017-03-11 16:00:42, 2017-03-18 16:00:42, 100, 2))",
          "code": "HY000",
          "status_code": 500
     }
  }
  </code></pre>
  
  <p><strong>PHP 2:</strong></p>
  
  <pre><code>$result =  DB::select('CALL rentalsAvailables_get(:p0, :p1, :p2, :p3)',
                  array(
                      'p0' =&gt; Carbon::now(),
                      'p1' =&gt; Carbon::now()-&gt;addDays(7),
                      'p2' =&gt; 100,
                      'p3' =&gt; 2
                  )
      );
  return var_dump($result);
  </code></pre>
  
  <p><strong>Result 2:</strong></p>
  
  <pre><code>array(0) {
  }
  </code></pre>
  
  <p>** Stored Procedure: **</p>
  
  <pre><code>    DELIMITER $$
  CREATE DEFINER=`root`@`localhost` PROCEDURE `rentalsAvailables_get`(IN `startDate` DATETIME, IN `endDate` DATETIME, IN `maxPrice` INT(11) ZEROFILL, IN `capacity` INT(2))
      NO SQL
  SELECT a.rentalId, a.rentalName, a.rentalBathroom, a.rentalBedroom, a.rentalCapacity, a.rentalCover, a.rentalLat, a.rentalLong, a.rentalLocation, a.rentalStatus, a.rentalSummary, a.rentalText, a.rentalOwnerId,
  b.rentalTypeId, b.rentalTypeName,
  c.id as 'userId', c.name,
  d.rentalPriceId, d.rentalPrice
  
  FROM rentals as a
  INNER JOIN rentalTypes as b
  ON a.rentalTypeId = b.rentalTypeId
  INNER JOIN users as c
  ON a.rentalOwnerId = c.id
  INNER JOIN rentalprice as d
  ON a.rentalId = d.rentalId
  
  WHERE a.rentalCapacity &gt; @p3
  AND a.rentalStatus = true
  AND d.rentalPrice &lt; @p2
  AND d.rentalPriceStartDate &lt;= @p0
  AND d.rentalPriceEndDate &gt;= @p1
  AND a.rentalId NOT IN (
          SELECT eSub.rentalId FROM unavailabilities as eSub WHERE eSub.unavailabilityStartDate &gt;= @p0 AND eSub.unavailabilityEndDate &lt;= @p1
      )
  AND a.rentalId NOT IN (
          SELECT fSub.rentalId FROM rent as fSub WHERE fSub.rentStartDate &gt;= @p0 AND fSub.rentEndDate &lt;= @p1
      )$$
  DELIMITER ;
  </code></pre>
  
  <p><strong>Note:</strong></p>
  
  <p>I have of course checked and i am getting results from my query when calling it like that:</p>
  
  <pre><code>SET @p0='2017-03-11 04:26:09.000000';
  SET @p1='2017-03-17 04:26:09.000000';
  SET @p2='1000';
  SET @p3='2';
  CALL `rentalsAvailables_get`(@p0, @p1, @p2, @p3);
  </code></pre>
  
  <p>Did anyone already got this issue?
  Thanks for reading</p>