note 110565 added to function.sqlsrv-query

From: Date: Wed, 07 Nov 2012 16:55:13 +0000
Subject: note 110565 added to function.sqlsrv-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-191795@lists.php.net to get a copy of this message
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 ---- Server IP: 69.147.83.199 Probable Submitter: 93.41.230.173 ---- Manual Page -- http://www.php.net/manual/en/function.sqlsrv-query.php Edit -- https://master.php.net/note/edit/110565 Del: integrated -- https://master.php.net/note/delete/110565/integrated Del: useless -- https://master.php.net/note/delete/110565/useless Del: bad code -- https://master.php.net/note/delete/110565/bad+code Del: spam -- https://master.php.net/note/delete/110565/spam Del: non-english -- https://master.php.net/note/delete/110565/non-english Del: in docs -- https://master.php.net/note/delete/110565/in+docs Del: other reasons-- https://master.php.net/note/delete/110565 Reject -- https://master.php.net/note/reject/110565 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#191795) next »