Welcome Guest, Not a member yet? Register   Sign In
SQLSRV Multiple Results from SP
#1

[eluser]sdjones[/eluser]
HI I have a requirement to use a certain stored procedure (SP) on MSSQL Server 2008

This SP runs multiple SELECT statements and returns, on success, multiple results (only 1 result on failure)

what i cant seem to do is loop through the result sets and grab all the results, is this possible using CI 2.x and the latest sqlsrv drivers?

any help is vastly appreciated.
#2

[eluser]mobs6[/eluser]
i'have already faced the same problem too with CI active record.
as i sugggested from my long searching on Goog's, theres only one solution that's really worked for me.
Read this basic post:
http://developer99.blogspot.com/2011/07/...m-php.html

this is the example how i used my CI to called out my SP in MSSQL 2008:

Sp Name was : EXEC CREATEPRODUCT
In : ProductNamee, Price , @ProductCode, MerchantId

Please read this part, which paramater u want to set as the output:
$addProduct = $this->db->query("
DECLARE @ProductCode as varchar (100) ;
EXEC CREATEPRODUCT
'$pname', '$price',
@ProductCode OUTPUT,
'$merchantId';
select @ProductCode;
")->result_array();



$productCode = $addProduct[0][0];

Note: in my experience of using mssql DB with PHP, after doing some query or etc..dont forget always close DB conection. in CI just used $this->db->close();
it will reduce memory usage of MSSQL SERVER.

ok hope it will help






Theme © iAndrew 2016 - Forum software by © MyBB