我一直试图通过使用FreeTDS使用PHP_PDO ODBC来回复MS SQL的输出
我对FreeTDS的配置如下
Compile-time settings (established with the "configure" script)
Version: freetds v0.95.95
freetds.conf directory: /usr/local/Cellar/freetds/0.95.95/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 7.3
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
OpenSSL: yes
GnuTLS: no
这个程序要执行,如何获得@Identity的价值
DECLARE
@Identity varchar(50),
@Header_DocNo int
EXEC Patient_Invoice
@Header_ID = N'-1',
@Header_PatientID = N'CP.1',
@Header_UserID = N'COP.1',
@Identity = @Identity OUTPUT,
@Header_DocNo = @Header_DocNo OUTPUT,
@Hosp_Code = N'COP',
@Header_RandomNo = N'-1'
SELECT @Identity as N'@Identity',
@Header_DocNo as N'@Header_DocNo'
这是我用于调用MS SQL过程的PHP函数。
public function postHeaderInvoice($data) {
if (!empty($data) && is_array($data)) {
$procedure = "Exec Patient_Invoice @Header_ID = ?, @Header_PatientID = ?, @Header_UserID = ?,"
. " @Header_DocNo =?, @Hosp_Code = ? , @Header_RandomNo = ?, @Identity = 0";
$query = Yii::app()->db->createCommand($procedure);
$query->bindValue(1, $data['Header_ID'], PDO::PARAM_STR);
$query->bindValue(2, $data['Header_PatientID'], PDO::PARAM_STR);
$query->bindValue(3, $data['Header_UserID'], PDO::PARAM_STR);
$query->bindValue(4, $data['Header_DocNo'], PDO::PARAM_INT);
$query->bindValue(5, $data['Hosp_Code'], PDO::PARAM_STR);
$query->bindValue(6, $data['Header_RandomNo'], PDO::PARAM_STR);
try {
$execute = $query->execute();
} catch (CDbException $e) {
$this->result = $this->sanitizeException($e);
}
}
}