Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从php将参数传递到存储过程中_Php_Sql Server - Fatal编程技术网

如何从php将参数传递到存储过程中

如何从php将参数传递到存储过程中,php,sql-server,Php,Sql Server,我在sql server中有一个存储过程'spGetOrderByID' 它根据给定的订单id提供记录 在我尝试使用sql server时,存储过程运行良好 这是iam使用的php代码 $this->_connectionString = mssql_connect($host, $username, $password) or die("can't connect to server1"); $this->_dbName ='databaseName"; $selectDB = m

我在sql server中有一个存储过程'spGetOrderByID'

它根据给定的订单id提供记录

在我尝试使用sql server时,存储过程运行良好

这是iam使用的php代码

$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:让我知道sored进程的结果将是$orderId,对吗

2:我是否需要在php中设置任何新的设置,以使存储过程正常工作。但我已经可以成功连接ms sql server了

3:现在我收到警告:mssql_执行:存储过程执行失败


请告诉我您使用的是msql_bind命令。因此:

$sp = mssql_init('stored_p', $db);
mssql_bind($sp, "@varInput", $input, VARCHAR, false, false);
mssql_execute($sp,$db);
其中varInput对应于存储过程中声明的输入变量。可以以类似的方式分配输出变量。通过执行多个msql_bind命令,将不同的PHP变量绑定到不同的存储过程变量,可以分配多个输入和输出变量


有关更多信息和示例,请访问

如何获取存储过程的结果如果您在输出参数上使用mssql_bind,那么绑定的php变量将包含存储过程的输出变量HI,请再次检查我的问题说明。我已更改了说明,请提供建议