freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Alexander Urmazov" <alexurm AT gmail.com>
- To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
- Subject: [freetds] Output parameter issue
- Date: Thu, 16 Mar 2006 13:45:18 +0300
Hi!
I have an issue with SP output parameter in 0.64RC1 - this parameter is not
returns in PHP.
When I call the mssql_execute the output parameter (@PersonId) is not set.
In SQL Profiler I see that output parameter returns (have value of 81 or
0x51 in this case)
I see this parameter also in freetds.log (attached, the last received
packet)
But I cannot see this value in PHP.
The SP header is:
CREATE PROCEDURE dbo.pr_person_ins_utf8
(
@PersonId int OUTPUT,
@PersonName varchar(100),
@PersonFirstName varchar(50),
@PersonLastName varchar(50),
@PersonMessage varchar(1000)
)
I use the following PHP code:
<?php
require_once("business/config.php");
require_once("business/entity.php");
require_once("business/da.person.php");
$parameters = array(
array('name' => '@PersonName', 'type' => SQLVARCHAR, 'value' =>
'TestPersonName'),
array('name' => '@PersonFirstName', 'type' => SQLVARCHAR, 'value' =>
'TestPersonFirstName'),
array('name' => '@PersonLastName', 'type' => SQLVARCHAR, 'value' =>
'TestPersonLastName'),
array('name' => '@PersonMessage', 'type' => SQLVARCHAR, 'value' =>
'TestPersonMessage'),
array('name' => '@PersonId', 'type' => SQLINT4, 'output' => TRUE)
);
$conn = mssql_connect(DBServer, DBLogin, DBPassword);
if ($conn == FALSE) return array(error => 'Cannot connect to DB
server');
if (mssql_select_db(DBName, $conn) == FALSE) return array(error =>
'Cannot select database');
$proc = mssql_init('dbo.pr_person_ins_utf8', $conn);
$varr=0;
foreach($parameters as $param) {
$isNull = !isset($param['value']);
$isOutput = isset($param['output']);
if ($isOutput) {
mssql_bind($proc, $param['name'], $varr, $param['type'], TRUE,
FALSE, 4);
} else {
mssql_bind($proc, $param['name'], $param['value'],
$param['type'], FALSE, $isNull, -1);
}
}
mssql_execute($proc, FALSE);
mssql_close($conn);
var_dump($varr);
?>
Attachment:
freetds.log.zip
Description: Zip archive
- [freetds] Output parameter issue, Alexander Urmazov, 03/16/2006
Archive powered by MHonArc 2.6.24.