【发布时间】:2013-05-14 09:37:52
【问题描述】:
我使用带有 Microsoft 3.0 驱动程序的 PHP 5.4 在 SQL Server 2008 中执行存储过程。它工作正常,直到我执行一个不返回任何结果的过程,因为它只是在执行更新。我得到的错误信息是:
SQLSTATE[IMSSP]: The active result for the query contains no fields.
不工作的过程归结为这个简单的代码:
CREATE PROCEDURE [dbo].[sp_communication_increase_trials]
@comId bigint = NULL
AS
BEGIN
SET NOCOUNT ON
IF NOT @comId IS NULL
BEGIN
UPDATE Communication SET CommunicationTrials = CommunicationTrials + 1 WHERE id = @comId;
END;
END
执行上述过程时,fetchAll 方法处的 PHP 代码错误:
if ($stmt->execute()) {
do {
$rowset = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rowset) {
$results[] = $rowset;
}
} while ($stmt->nextRowset());
}
return $results;
但是,在过程中的更新语句之后添加一个简单的选择可以使其工作,但这不是必需的。
【问题讨论】:
标签: php sql-server stored-procedures pdo