title: PDO Stored Procedure return value
body: <p>I'm working with a SQL Server stored procedure that returns error codes; here is a very simple snippet of the SP.</p>
  
  <pre><code>DECLARE @ret int
  BEGIN
  SET @ret = 1
  RETURN @ret
  END
  </code></pre>
  
  <p>I can get the return value with the mssql extension using:</p>
  
  <pre><code>mssql_bind($proc, "RETVAL", &amp;$return, SQLINT2);
  </code></pre>
  
  <p>However, I can't figure out how to access the return value in PDO; I'd prefer not to use an OUT parameter, as alot of these Stored Procedures have already been written. Here is an example of how I am currently calling the procedure in PHP.</p>
  
  <pre><code>$stmt = $this-&gt;db-&gt;prepare("EXECUTE usp_myproc ?, ?");
  $stmt-&gt;bindParam(1, 'mystr', PDO::PARAM_STR);
  $stmt-&gt;bindParam(2, 'mystr2', PDO::PARAM_STR);
  $rs = $stmt-&gt;execute();
  $result = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
  </code></pre>