如何使用 Adodb 库 PHP 在 UPDATE 查询中查找受影响的行?

How to find affected rows in UPDATE query using Adodb library PHP?

我正在使用 Adodb PHP 库来处理数据库函数。大多数功能已使用存储过程处理。但是,在少数情况下,我需要编写快速自定义查询来完成流程。

代码:

$Result = array();
$this->DB->SetFetchMode(ADODB_FETCH_ASSOC);
$Result = $this->DB->PrepareSP("UPDATE Member SET FirstName = '" . $param['FirstName'] . "', LastName = '" . $param['LastName'] . "', Email = '".$param['Email']."', DateOfBirth = '".$param['DateOfBirth']."', HoroscopeID = ".$param['HoroscopeID'].", Gender = '".$param['Gender']."', CountryID = ".$param['CountryID']." WHERE ID = ".$param['MemberId'].";SELECT @@IDENTITY AS AffectedRows;");
        $Result = $this->DB->GetArray($Result);

结果:

array (size=1)
  0 => 
    array (size=1)
      'AffectedRows' => null

我也试过:

$this->DB->affected_rows();

每次都是returns0。我已经在 navicat 上回显了内部查询和 运行,它工作正常。但是,当它通过代码调用时,它不会更新任何记录。

以下是如何访问 ADOdb 中的存储过程输出数据:

/*
* Your stored procedure preparation returns a handle
*/
$procedure = $this->DB->prepareSp("your statement...");

/*
* You prepare and set an output parameter to receive your affected rows
* The name of the parameter matches the stored procedure variable
*/
$outParameterName  = 'AffectedRows';
$outParameterValue = 0;

$ok = $this->DB->outParameter($procedure,$outParameterName,$outParameterValue);

/*
* Execute the procedure handle , it is an update so a resultset is not returned
*/
$result = $this->DB->execute($procedure);

/*
* The value of the Affected rows is now available in your out Parameter value
*/ 
print "AffectedRows IS NOW $outParameterValue";