[freetds] Output parameter issue
Alexander Urmazov
alexurm at gmail.com
Thu Mar 16 05:45:18 EST 2006
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);
?>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freetds.log.zip
Type: application/zip
Size: 3520 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20060316/ec0c6b3b/attachment.zip
More information about the FreeTDS
mailing list