note 89506 modified in function.mssql-query by danbrown

From: Date: Wed, 11 Mar 2009 14:55:51 +0000
Subject: note 89506 modified in function.mssql-query by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151738@lists.php.net to get a copy of this message
hello all! here's a tip for those of you that, just like me, had some problems on how to get values from a call to a Stored Procedure that returns Multiple Recordsets. <?php conn = mssql_connect($server, $user, $pass, $db); $sql ="EXEC WhateverSProcYouWant some_arguments"; $data = mssql_query( $sql, $conn); $result = array(); do { while ($row = mssql_fetch_object($data)){ $result[] = $row; } }while ( mssql_next_result($data) ); mssql_close($conn); ?> this will create 2 loops: 1 - which loops through all returned recordsets. mssql_next_result will step through each recordsets 2 - this inner-loop will return all rows, as objects, from current recordset and add each object to the $result array. and that's it! HTH, has i haven't found any info/docs related to multiple recordsets --was-- hello all! here's a tip for those of you that, just like me, had some problems on how to get values from a call to a Stored Procedure that returns Multiple Recordsets. conn = mssql_connect($server, $user, $pass, $db); $sql ="EXEC WhateverSProcYouWant some_arguments"; $data = mssql_query( $sql, $conn); $result = array(); do { while ($row = mssql_fetch_object($data)){ $result[] = $row; } }while ( mssql_next_result($data) ); mssql_close($conn); this will create 2 loops: 1 - which loops through all returned recordsets. mssql_next_result will step through each recordsets 2 - this inner-loop will return all rows, as objects, from current recordset and add each object to the $result array. and that's it! HTH, has i haven't found any info/docs related to multiple recordsets http://php.net/manual/en/function.mssql-query.php

« previous php.notes (#151738) next »