note 110565 deleted from function.sqlsrv-query by aharvey
| From: | aharvey@php.net | Date: | Thu, 08 Nov 2012 01:44:54 +0000 |
| Subject: | note 110565 deleted from function.sqlsrv-query by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191804@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
Question
Im using php 5.4 with sqlsrv extension and I'm trying to call this sample stored procedure
(NorthWind database):
create PROCEDURE [dbo].[GetCategories]
@CategoryID int = null
AS
SELECT * from dbo.Categories where CategoryID= IsNull(@CategoryID,CategoryID)
And I'm using this sqlsrv_query syntax:
$sql = "{ call dbo.GetCategories (?)}";
$catID=2;
$params = array($catID);
$stmt = sqlsrv_query( $conn, $sql,$params);
I want to specify parameter name and value in $params, just like this:
$sql = "dbo.GetCategories";
$catID=2;
$params = array("@CategoryID"=>$catID);
$stmt = sqlsrv_query( $conn, $sql,$params);
It return this error: String keys are not allowed in parameters arrays.
How can i solve this problem? Thanks