Subject | How to get result from insert... returning ... SQL statement? Related to Yii2 Firebird extension. |
---|---|
Author | |
Post date | 2016-09-13T09:58:31Z |
Hi!
I have an SQL statement:
$this->pdoStatement->execute();
$this->pdoStatement->fetch();
Some developers have said to me, that Firebird handles insert... returning... in the same manner as stored procedure without suspend command, i.e., they say: it is not possible to use fetch for getting results from such SQL statements and one is required to use prepared statements with bound output parameters.
I believe them, but the problem is - Yii2 yii/db/Command.php queryInternal procedure assumes that it is possible to get result from insert... into... using fetch() command. In reality the exception is raised:
SQLSTATE[HY000]: General error: -502 Cursor is not open
So - my questions are:
1) is Yii2 assumption about PDO handling of select... returning.... correct and if it is correct then one should deduce, that Firebird PDO driver is not working according to the PHP PDO PHP Data Objects specifiction? Who maintains pdf_firebird.dll and is it possible to arrive at the correct behavior.
2) Do anyone uses Yii2 Firebird extension (driver)? I am trying to use it with Firebird 2.1 dialect 2.1 database and the select commands works but it is completely impossible to execute insert command due to the situation described above. I am working to debug and correct code but if PHP PDO driver is not working like PDO drivers for other databases then the correction is not possible without changing the Yii internal code? So, maybe pdo_firebird.dll should be corrected.
My question has related stackoverflow questions:
How to retrieve the result of a Firebird INSERT ... RETURNING in Yii
I have an SQL statement:
INSERT INTO CONTRACTS (contract_no) VALUES (10002) RETURNING contract_no
And I would like the the the result using PHP Firebird PDO commands:$this->pdoStatement->execute();
$this->pdoStatement->fetch();
Some developers have said to me, that Firebird handles insert... returning... in the same manner as stored procedure without suspend command, i.e., they say: it is not possible to use fetch for getting results from such SQL statements and one is required to use prepared statements with bound output parameters.
I believe them, but the problem is - Yii2 yii/db/Command.php queryInternal procedure assumes that it is possible to get result from insert... into... using fetch() command. In reality the exception is raised:
SQLSTATE[HY000]: General error: -502 Cursor is not open
So - my questions are:
1) is Yii2 assumption about PDO handling of select... returning.... correct and if it is correct then one should deduce, that Firebird PDO driver is not working according to the PHP PDO PHP Data Objects specifiction? Who maintains pdf_firebird.dll and is it possible to arrive at the correct behavior.
2) Do anyone uses Yii2 Firebird extension (driver)? I am trying to use it with Firebird 2.1 dialect 2.1 database and the select commands works but it is completely impossible to execute insert command due to the situation described above. I am working to debug and correct code but if PHP PDO driver is not working like PDO drivers for other databases then the correction is not possible without changing the Yii internal code? So, maybe pdo_firebird.dll should be corrected.
My question has related stackoverflow questions:
How to retrieve the result of a Firebird INSERT ... RETURNING in Yii
Use of PHP PDO with Firebird INSERT... RETURNING / STORED PROCEDURE without SUSPEND