开发者

How to pass parameter into stored proceedure from php

I have a stor开发者_JAVA技巧ed Proceedure 'spGetOrderByID' in the sql server.

Which gives a record according the given order id.

And the stored proceedure is working fine , while i trying in the sql server.

This is the php code iam using

$this->_connectionString = mssql_connect($host, $username, $password) or die("can't connect to server1");
$this->_dbName ='databaseName";
$selectDB = mssql_select_db($this->_dbName, $this->_connectionString ) or die('Databse error'); 

$sp = mssql_init('spGetOrderByID',  $this->_connectionString);
$orderId =824;

mssql_bind($sp, "@orderID", $orderId, SQLINT1, false, false);
mssql_execute($sp,$this->_dbName);

echo $orderId;

1: let me know the result of the sored proceedure will be in $orderId, right?

2: Do i need to set a any new setting in php, for the stored proceedure to working.But already i can connect the ms sql server successfully

3: Now i getting Warning: mssql_execute(): stored procedure execution failed

Please advise me


You use the msql_bind command. As such:

$sp = mssql_init('stored_p', $db);
mssql_bind($sp, "@varInput", $input, VARCHAR, false, false);
mssql_execute($sp,$db);

Where varInput corresponds to an input var declared in the stored procedure. Output vars can be assigned in a similar fashion. You can assign multiple input and output vars by making multiple msql_bind commands, binding different PHP vars to different stored procedure vars.

For more info and examples, visit http://php.net/manual/en/function.mssql-bind.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜