Use of PHP PDO with Firebird INSERT… RETURNING / S

2019-07-30 16:49发布

问题:

I have PHP code that executes PDOStatement and tries to fetch the returned data:

$this->pdoStatement->execute();
$this->pdoStatement->fetch();

The SQL of PDO statement is:

INSERT INTO CONTRACTS (contract_no) VALUES (10010) RETURNING contract_no

But the stored procedure without suspend clause can also be here. The problem is that the mentioned sequence of PHP PDO commands return the following error while executing fetch:

SQLSTATE[HY000]: General error: -502 Cursor is not open 

How and is it possible at all to get data from insert... into from Firebird using PHP Data Objects PDO?

This question has a wider context - I try to use Yii 2.0 with Firebird using plugin http://www.yiiframework.com/extension/yii2-firebird/ and I have discovered that the insert command is not working due the problem described in this question.

Firebird 2.1.

回答1:

Try upgrading PHP. I've fixed some bugs in the PHP7 Firebird PDO extension, including statements with "returning" clause.