note 39611 added to function.mssql-query

From: Date: Wed, 04 Feb 2004 15:50:06 +0000
Subject: note 39611 added to function.mssql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-64635@lists.php.net to get a copy of this message
You can run a stored proceedure AND get back a result set from mssql_query(). I figured this little trick out when I realized I couldn't use the mssql_init() function group for my stored procedure stuff as I needed datetime variables to be passed, and they are not supported. However, you can "encapsulate" a snippet of stored procedure within a normal query that can be executed via mssql_query() and have a result value returned. For example, here's a query which passes a store's local date and time to a stored procedure that converts it to the GMT values that is used internally by the rest of the database structure: $temptime=time(); $storeid = 68; $deptid = 70; $StartDate = strftime("%b %d %Y %H:%M:%S",$temptime); $spquery=" BEGIN DECLARE @date datetime, @GMreturn datetime SELECT @date='$StartDate' execute TZ_toGMT '$storeid','$deptid',@date,@GMreturn OUTPUT SELECT @GMreturn END"; Now, when $spquery is passed to mssql_query(), it will return with a value for @GMreturn, which can be parsed out with mssql_fetch_array() as with any other query. ---- Manual Page -- http://www.php.net/manual/en/function.mssql-query.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39611 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39611&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39611&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64635) next »