我在MSSQL服务器2012上从存储过程获取结果时遇到问题。使用PHP 5.4.34,dblib,CentOS。在我的开发中,我使用sqlsrv扩展为PHP一切正常。
PDO INIT:
$this->pdo = new PDO('dblib:host=88.88.88.88;dbname=dbName', $connection['login'], $connection['pass'] );
并致电程序:
$sqlStr = "DECLARE @price decimal(15, 4), @resutl tinyint, @err_message varchar(1000), @act_list char(16), @act_list_poradi smallint;
EXEC [dba].[get_price] @arg_id_cust = ?, @arg_cislo_nomenklatury = ?, @arg_mnozstvi = ?,@arg_id_mj = ?, @typ_param = ?,@price = @price OUTPUT,@resutl = @resutl OUTPUT, @err_message = @err_message OUTPUT, @act_list = @act_list OUTPUT, @act_list_poradi = @act_list_poradi OUTPUT;
SELECT @price as cena";
$sth = $this->kPDO->prepare($sqlStr);
if ($sth){
$sth->bindParam(1, $idCust);
$sth->bindParam(2, $idNomen);
$sth->bindParam(3, $ks);
$sth->bindParam(4, $mj);
$sth->bindParam(5, $param);
$res = $sth->execute();
}else{
throw new Exception('Chybny statement');
}
$ res为true,但是$ sth-> fetch()返回FALSE并且没有错误被忽略。
感谢您的帮助。